Click here to Skip to main content
14,330,663 members

C / C++ / MFC

 
AnswerRe: How can I have several hundred of #if defined(XXX) ... #endif in an easy-to-read table format? Pin
CPallini10-Oct-19 3:03
mveCPallini10-Oct-19 3:03 
GeneralRe: How can I have several hundred of #if defined(XXX) ... #endif in an easy-to-read table format? Pin
arnold_w10-Oct-19 4:27
memberarnold_w10-Oct-19 4:27 
GeneralRe: How can I have several hundred of #if defined(XXX) ... #endif in an easy-to-read table format? Pin
CPallini10-Oct-19 6:12
mveCPallini10-Oct-19 6:12 
QuestionProblem with AlphaBlend. Pin
Member 126614649-Oct-19 6:57
memberMember 126614649-Oct-19 6:57 
QuestionRe: Problem with AlphaBlend. Pin
Richard MacCutchan9-Oct-19 8:49
protectorRichard MacCutchan9-Oct-19 8:49 
AnswerRe: Problem with AlphaBlend. Pin
Member 126614649-Oct-19 9:09
memberMember 126614649-Oct-19 9:09 
GeneralRe: Problem with AlphaBlend. Pin
Richard MacCutchan9-Oct-19 9:34
protectorRichard MacCutchan9-Oct-19 9:34 
QuestionPassing a "value", that was either #defined or #undef, into a macro and check if it was defined? Pin
arnold_w9-Oct-19 6:07
memberarnold_w9-Oct-19 6:07 
I want to create a macro that is fully executed at compile time (not runtime). If two values are both defined, then I want to check if they are equal. If at least one of them is not defined, then nothing should happen. I have come halfway, the following works great:
#define VALIDATE_ADDR(ADDR1,ADDR2)  _Static_assert(ADDR1 == ADDR2, #ADDR1 " is not equal to " #ADDR2);
However, when I try to nest that macro into another macro, then I run into trouble:
#define VALIDATE_ADDR_IF_THEY_BOTH_EXIST(ADDR1,ADDR2)   \
#if defined(ADDR1) && defined(ADDR2)                    \
   VALIDATE_ADDR(ADDR1, ADDR2)                          \
#endif
Can someone please help me so I can do checks like this:
#define MY_ADDR_1  (1)
#define MY_ADDR_2  (2)
#define MY_ADDR_3  (3)
#ifdef MY_ADDR_4
#undef MY_ADDR_4
#endif

VALIDATE_ADDR_IF_THEY_BOTH_EXIST(MY_ADDR_1, MY_ADDR_2); // Compile time error since MY_ADDR_1 != MY_ADDR_2
VALIDATE_ADDR_IF_THEY_BOTH_EXIST(MY_ADDR_3, MY_ADDR_4); // Compiles just fine since MY_ADDR_4 is not defined

AnswerRe: Passing a "value", that was either #defined or #undef, into a macro and check if it was defined? Pin
k50549-Oct-19 6:48
memberk50549-Oct-19 6:48 
AnswerRe: Passing a "value", that was either #defined or #undef, into a macro and check if it was defined? Pin
Richard MacCutchan9-Oct-19 8:47
protectorRichard MacCutchan9-Oct-19 8:47 
GeneralRe: Passing a "value", that was either #defined or #undef, into a macro and check if it was defined? Pin
arnold_w9-Oct-19 9:14
memberarnold_w9-Oct-19 9:14 
GeneralRe: Passing a "value", that was either #defined or #undef, into a macro and check if it was defined? Pin
Richard MacCutchan9-Oct-19 9:51
protectorRichard MacCutchan9-Oct-19 9:51 
AnswerRe: Passing a "value", that was either #defined or #undef, into a macro and check if it was defined? Pin
arnold_w9-Oct-19 9:18
memberarnold_w9-Oct-19 9:18 
QuestionString Table MFC vc++ Pin
Member 145755569-Oct-19 1:59
memberMember 145755569-Oct-19 1:59 
AnswerRe: String Table MFC vc++ Pin
Member 145755569-Oct-19 2:04
memberMember 145755569-Oct-19 2:04 
GeneralRe: String Table MFC vc++ Pin
Maximilien9-Oct-19 22:00
memberMaximilien9-Oct-19 22:00 
GeneralRe: String Table MFC vc++ Pin
Member 145755569-Oct-19 22:20
memberMember 145755569-Oct-19 22:20 
QuestionSingleton Design Pattern for Database connection in MFC vc++ Pin
Member 145755566-Oct-19 18:24
memberMember 145755566-Oct-19 18:24 
AnswerRe: Singleton Design Pattern for Database connection in MFC vc++ Pin
_Flaviu6-Oct-19 19:38
member_Flaviu6-Oct-19 19:38 
GeneralRe: Singleton Design Pattern for Database connection in MFC vc++ Pin
Member 145755566-Oct-19 21:29
memberMember 145755566-Oct-19 21:29 
GeneralRe: Singleton Design Pattern for Database connection in MFC vc++ Pin
_Flaviu6-Oct-19 21:55
member_Flaviu6-Oct-19 21:55 
GeneralOT Pin
Richard MacCutchan6-Oct-19 23:03
protectorRichard MacCutchan6-Oct-19 23:03 
GeneralRe: OT Pin
_Flaviu6-Oct-19 23:32
member_Flaviu6-Oct-19 23:32 
GeneralRe: OT Pin
Richard MacCutchan7-Oct-19 2:35
protectorRichard MacCutchan7-Oct-19 2:35 
Questionidentifier 'mode_t' Pin
_Flaviu6-Oct-19 8:08
member_Flaviu6-Oct-19 8:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.