syntax error

This is a discussion on syntax error within the Linux Programming forums, part of the Platform Specific Boards category; why am i getting the error synatx error before ":" void main() { int i:3; } now when in memory ...

  1. #1
    Unregistered
    Guest

    syntax error

    why am i getting the error
    synatx error before ":"

    void main()
    {
    int i:3;
    }


    now when in memory what will be the size of the integer will it be of 4 bytes or will it take 3 bits actually.


    also if i have to use similar ones like int i:3,j:4:k:1

    now how do i access i,j,k individually

  2. #2
    Registered User alex's Avatar
    Join Date
    Sep 2001
    Posts
    132
    You can only use bit fields in structs (that's way the compiler complains about a syntax error):

    Code:
    struct MYBITFIELD
    {
       unsigned int i:3;
       unsigned int j:4;
       unsigned int k:1;
    }
    bit;
    you can access these fields using the dot "." operator: bit.i

    The amount of memory used depends on the compiler, but usually the components of the bitfield are packed in units of size "sizeof(int)".

    alex

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 11:52 PM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM

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