Click here to Skip to main content
15,886,110 members
Home / Discussions / C / C++ / MFC
   

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
arnold_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
Member 126614649-Oct-19 6:57 
QuestionRe: Problem with AlphaBlend. Pin
Richard MacCutchan9-Oct-19 8:49
mveRichard MacCutchan9-Oct-19 8:49 
AnswerRe: Problem with AlphaBlend. Pin
Member 126614649-Oct-19 9:09
Member 126614649-Oct-19 9:09 
GeneralRe: Problem with AlphaBlend. Pin
Richard MacCutchan9-Oct-19 9:34
mveRichard 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
arnold_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:
C++
#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:
C++
#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:
C++
#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
mvek50549-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
mveRichard 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
arnold_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
mveRichard 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
arnold_w9-Oct-19 9:18 
QuestionString Table MFC vc++ Pin
Member 145755569-Oct-19 1:59
Member 145755569-Oct-19 1:59 
AnswerRe: String Table MFC vc++ Pin
Member 145755569-Oct-19 2:04
Member 145755569-Oct-19 2:04 
GeneralRe: String Table MFC vc++ Pin
Maximilien9-Oct-19 22:00
Maximilien9-Oct-19 22:00 
GeneralRe: String Table MFC vc++ Pin
Member 145755569-Oct-19 22:20
Member 145755569-Oct-19 22:20 
QuestionSingleton Design Pattern for Database connection in MFC vc++ Pin
Member 145755566-Oct-19 18:24
Member 145755566-Oct-19 18:24 
AnswerRe: Singleton Design Pattern for Database connection in MFC vc++ Pin
_Flaviu6-Oct-19 19:38
_Flaviu6-Oct-19 19:38 
GeneralRe: Singleton Design Pattern for Database connection in MFC vc++ Pin
Member 145755566-Oct-19 21:29
Member 145755566-Oct-19 21:29 
GeneralRe: Singleton Design Pattern for Database connection in MFC vc++ Pin
_Flaviu6-Oct-19 21:55
_Flaviu6-Oct-19 21:55 
GeneralOT Pin
Richard MacCutchan6-Oct-19 23:03
mveRichard MacCutchan6-Oct-19 23:03 
GeneralRe: OT Pin
_Flaviu6-Oct-19 23:32
_Flaviu6-Oct-19 23:32 
GeneralRe: OT Pin
Richard MacCutchan7-Oct-19 2:35
mveRichard MacCutchan7-Oct-19 2:35 
Questionidentifier 'mode_t' Pin
_Flaviu6-Oct-19 8:08
_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.