Thread: macros and size of

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    569

    macros and size of

    sizes.h:7:11: error: missing binary operator before token "("


    the error above always occurs in this code and I don't know whats wrong..


    Code:
    #ifndef SIZES_H_
    #define SIZES_H_
    
    #include <stdlib.h>
    
    /* Figure out how big your integers need to be */
    #if(sizeof(long int) == 4)
    typedef unsigned long int       int_u8;
    typedef unsigned int            int_u4;
    typedef unsigned short int      int_u2;
    typedef unsigned char           int_u1;
    typedef long int                int_8;
    typedef int                     int_4;
    typedef short int               int_2;
    typedef char                    int_1;
    #else
    typedef unsigned long long int  int_u8;
    typedef unsigned long int       int_u4;
    typedef unsigned short int      int_u2;
    typedef unsigned char           int_u1;
    typedef long long int           int_8;
    typedef long int                int_4;
    typedef short int               int_2;
    typedef char                    int_1;
    #endif
    
    #endif /* SIZES_H_ */

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    #if is evalueted by preprocessor
    sizeof - by compiler... so you are trying to set a cart before the horse
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    hmm..so how can I do this?? I am trying to see if my machine is a 32 bit or not and assign the correct typedef ...

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    you should look for your project settings - for example my Win32 project settings include WIN32 define i can use in this #ifdef construct

    I suppose the win64 configuration will include WIN64 define...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    how do I check that?

  6. #6
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by -EquinoX- View Post
    how do I check that?
    In VS - go to Project/Properties/C++/Preprocessor/Preprocessor Definitions

    In other IDEs It should be something similar
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  7. #7
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with macros..
    By sanddune008 in forum C Programming
    Replies: 4
    Last Post: 07-07-2009, 02:00 AM
  2. Bitfield
    By $l4xklynx in forum C Programming
    Replies: 26
    Last Post: 12-25-2008, 08:52 AM
  3. Macros
    By jsbeckton in forum C Programming
    Replies: 11
    Last Post: 12-02-2005, 02:10 AM