Click here to Skip to main content
15,902,189 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: error C2143 Pin
_Flaviu11-Oct-19 4:28
_Flaviu11-Oct-19 4:28 
GeneralRe: error C2143 Pin
Richard MacCutchan11-Oct-19 5:04
mveRichard MacCutchan11-Oct-19 5:04 
GeneralRe: error C2143 Pin
leon de boer15-Oct-19 2:58
leon de boer15-Oct-19 2:58 
AnswerRe: error C2143 Pin
David Crow10-Oct-19 10:44
David Crow10-Oct-19 10:44 
AnswerRe: error C2143 Pin
Daniel Pfeffer11-Oct-19 4:47
professionalDaniel Pfeffer11-Oct-19 4:47 
GeneralRe: error C2143 Pin
_Flaviu12-Oct-19 23:44
_Flaviu12-Oct-19 23:44 
GeneralRe: error C2143 Pin
_Flaviu12-Oct-19 23:46
_Flaviu12-Oct-19 23:46 
QuestionHow can I have several hundred of #if defined(XXX) ... #endif in an easy-to-read table format? Pin
arnold_w9-Oct-19 11:55
arnold_w9-Oct-19 11:55 
This question is somewhat related to the question Passing a "value", that was either #defined or #undef, into a macro and check if it was defined? - C / C++ / MFC Discussion Boards[^] , but the core question in this thread is quite different than that of the other thread so I think this should be a separate thread. In the other thread I was looking to have a macro do my checks, but it would be ok to do it without a macro as well. The important thing is that the checks (there are several hundreds of them) are nicely formatted in way that makes it easy to read. So, is it possible to achieve something like this with some clever workaround:
C++
#if defined(ADDR1) && defined(ADDR2) _Static_assert(ADDR1==ADDR2, #ADDR1 " is not equal to " #ADDR2);  #endif
#if defined(ADDR3) && defined(ADDR4) _Static_assert(ADDR3==ADDR4, #ADDR3 " is not equal to " #ADDR4);  #endif
#if defined(ADDR5) && defined(ADDR6) _Static_assert(ADDR5==ADDR6, #ADDR5 " is not equal to " #ADDR6);  #endif
#if defined(ADDR7) && defined(ADDR8) _Static_assert(ADDR7==ADDR8, #ADDR7 " is not equal to " #ADDR8);  #endif
As you can see, the "correct" way of doing this (the way the compiler wants it) is not easy to read at all (and not so easy to generate in Excel or edit using the block caret feature in Eclipse):
C++
#if defined(ADDR1) && defined(ADDR2)    
    _Static_assert(ADDR1 == ADDR2, #ADDR1 " is not equal to " #ADDR2);
#endif
#if defined(ADDR3) && defined(ADDR4)
    _Static_assert(ADDR3 == ADDR4, #ADDR3 " is not equal to " #ADDR4);
#endif
#if defined(ADDR5) && defined(ADDR6)
    _Static_assert(ADDR5 == ADDR6, #ADDR5 " is not equal to " #ADDR6);
#endif
#if defined(ADDR7) && defined(ADDR8)
    _Static_assert(ADDR7 == ADDR8, #ADDR7 " is not equal to " #ADDR8);
#endif
Can anyone think of a neat trick? Maybe something involving #include files? I think I've read somewhere that you can have several #include on the same line.

modified 9-Oct-19 18:19pm.

QuestionRe: How can I have several hundred of #if defined(XXX) ... #endif in an easy-to-read table format? Pin
Richard MacCutchan9-Oct-19 21:41
mveRichard MacCutchan9-Oct-19 21:41 
AnswerRe: How can I have several hundred of #if defined(XXX) ... #endif in an easy-to-read table format? Pin
arnold_w9-Oct-19 21:54
arnold_w9-Oct-19 21:54 
GeneralRe: How can I have several hundred of #if defined(XXX) ... #endif in an easy-to-read table format? Pin
Richard MacCutchan9-Oct-19 22:10
mveRichard MacCutchan9-Oct-19 22:10 
GeneralRe: How can I have several hundred of #if defined(XXX) ... #endif in an easy-to-read table format? Pin
arnold_w9-Oct-19 22:20
arnold_w9-Oct-19 22:20 
GeneralRe: How can I have several hundred of #if defined(XXX) ... #endif in an easy-to-read table format? Pin
Richard MacCutchan9-Oct-19 22:36
mveRichard MacCutchan9-Oct-19 22:36 
GeneralRe: How can I have several hundred of #if defined(XXX) ... #endif in an easy-to-read table format? Pin
arnold_w9-Oct-19 23:00
arnold_w9-Oct-19 23:00 
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 
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 

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.