Thread: newbie macro question

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    167

    newbie macro question

    Code:
    #define SET_QR(X) (X|0x8000)
    if i use it on
    [CODE]SET_QR(i);[CODE]

    i get:
    Code:
    client.c:37: warning: statement with no effect

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    The SET_QR macro shouldn't be an expression by itself. The end result of the macro is just a number, say 0xF800; to have an effect on the program, it needs to be part of a larger calculation. Numbers by themselves are not processing instructions.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    167
    i solved it
    Code:
    #define SET_QR(X) (X=X|0x8000)
    very silly problem.
    now... what does this declaration mean?
    Code:
    char a:1;
    does this declares a bit ?

  4. #4
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    It declares a bit field. You might think of an integer on your system like a 4-32-bit field, for instance.

    And you should under general circumstances use unsigned values in bit fields to avoid issues with signedness, where a negative number has a different bit pattern than you expect and get incorrect results from your bitwise operations. You also don't waste half the range supporting a sign that you won't use in calculation.
    Last edited by whiteflags; 05-11-2007 at 08:05 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Stupid Newbie question
    By TimL in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2008, 04:43 AM
  3. Newbie with Very Newbie Question
    By Jedi_Mediator in forum C++ Programming
    Replies: 18
    Last Post: 07-01-2008, 08:00 AM
  4. newbie: array question :(
    By cstudent in forum C Programming
    Replies: 2
    Last Post: 04-09-2008, 06:46 AM
  5. C prog newbie question
    By Draginzuzu in forum C Programming
    Replies: 1
    Last Post: 02-03-2003, 06:45 PM