Code Repo    |     RSS
MD's Technical Sharing



Monday, April 14, 2008

#define Preprocessor Directive

In C++: Define a constant:

#define UNICODE
//Check if a constant is defined:
#ifdef UNICODE
#define MessageBox MessageBoxW
#else
#define MessageBox MessageBoxA
#endif
//Undefine a constant
#undef UNICODE

In VB.NET - Define a constant:
  • #Const MyConst = TRUE (FALSE defaults to undefined)
  • Or in Project Properties>Compile>Advanced Compiler Settings>Custom Constants and type the custom constants, e.g.: Smartphone=TRUE, MyConst=TRUE
Check if a constant is defined:

#If MyConst = TRUE Then
'Do something
#else
'Do something
#end if

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.