macros and size of

This is a discussion on macros and size of within the C Programming forums, part of the General Programming Boards category; sizes.h:7:11: error: missing binary operator before token "(" the error above always occurs in this code and I don't know ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    #if is evalueted by preprocessor
    sizeof - by compiler... so you are trying to set a cart before the horse
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    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...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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

  6. #6
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    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
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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, 07:52 AM
  3. Macros
    By jsbeckton in forum C Programming
    Replies: 11
    Last Post: 12-02-2005, 01:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21