Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, I had a head file, looks like #define MIN_NUM 10 #define MAX_NUM 10 is there any way to get "MAX_NUM" from 10? thanks. peter...
  1. #1
    Just Joined!
    Join Date
    Apr 2011
    Posts
    4

    #define in c

    Hi,

    I had a head file, looks like
    #define MIN_NUM 10
    #define MAX_NUM 10


    is there any way to get "MAX_NUM" from 10?

    thanks.

    peter

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Simple answer? No. Why? Because many #defines may map the value 10 to some symbol. If you need to see what some #define symbol is equal to, then you can print it out, such as:
    Code:
    printf("MIN_NUM == %d, MAX_NUM == %d\n", MIN_NUM, MAX_NUM);
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Furthermore, #define is actually not part of C. Instead, it is part of the C preprocessor. By the time that your C compiler sees your source code, every instance of MAX_NUM has been replaced with 10.

    You could probably write a program that would look at C source code and print out every #define to a certain value, but there is certainly nothing built into C or the preprocessor that does this.
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...