CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Posts
    2

    Smile macro & preprocessor

    hello to all of u in this forum, i am a newbie on VisC++, so please help me to understand about something called macro & preprocessor

    1. what is the macro WIN_32_LEAN_AND_MEAN does to program ?
    2. is there any aim to write macro definition with '_' ? i mean something like this
    #define __Entity_H__
    3. what is the precompiler #pragma once does to program ?

    i would very appreciate if someone would answer my question

  2. #2
    Join Date
    May 2005
    Location
    United States
    Posts
    526

    Re: macro & preprocessor

    1. WIN32_LEAN_AND_MEAN excludes certain parts of the Win32 headers that aren't used too often. If you're curious as to exactly what is cut out, load the windows.h file. There's a number of headers that are included inside a #ifndef WIN32_LEAN_AND_MEAN ... #endif block, so those are dropped when you define that symbol.

    2. If by "aim" you mean some kind of functionality, no, it's just a naming convention. I'm not sure where it came from though. Perhaps having some leading or trailing underscores in there is just an attempt to make it less likely that that symbol will be in use by another header file somewhere.

    3. #pragma once ensures that the header file in which it appears won't be included multiple times unnecessarily.

  3. #3
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: macro & preprocessor

    To add to what Smasher/Devourer said:
    • (2) Generally, names with one or two leading underscores are reserved for compiler- or library-specific symbols and macros. You should avoid leading underscores in your own names.
    • (3) More generally, the #pragma directive allows compiler vendors to add functionality to their preprocessor in a compatible way. For example, the Visual C++ compiler knows #pragmas like pack, once, warning, check_stack and many others which influence the way the compiler generates code and are specific to the Visual C++ compiler. However, code using these pragmas will still be portable, since prprocessors just ignore unknown pragmas.

  4. #4
    Join Date
    Oct 2005
    Posts
    2

    Lightbulb Re: macro & preprocessor

    thanks for the explanation guys, now i got it clearer

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured