LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-22-2004, 08:10 AM   #1
cynthia
LQ Newbie
 
Registered: Sep 2004
Posts: 20

Rep: Reputation: 0
size of define


#define X 003

what is the size of X in memory? a char?

in a line like char x = X;
can be a loss of data?
 
Old 09-22-2004, 08:17 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
When you define a symbol with #define, you are instructing the preprocessor to replace every occurence of the X symbol in the text with the given string before compilation. So the symbol X never gets loaded into memory.

The program generated by that code would be identical to the program you would get if you had used:

char X = 003;

Is this case, there is no loss of data, because 3 fits quite nicely between the limits of char (-127 to +128).
 
Old 09-22-2004, 08:56 AM   #3
cynthia
LQ Newbie
 
Registered: Sep 2004
Posts: 20

Original Poster
Rep: Reputation: 0
thanks for your answer
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to define variables? Yig Linux - Software 3 08-24-2005 05:09 PM
define jhon Linux - Networking 2 08-30-2004 07:42 PM
gftp: define message size...ssh2 (message_size is too big) pablovschby Linux - Software 2 02-19-2004 11:23 AM
define main linuxanswer Programming 8 11-05-2003 02:02 PM
using #define Jo_Nak Programming 4 06-11-2003 01:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration