macros

string concatenation with macro [duplicate]

大兔子大兔子 提交于 2021-01-27 07:11:41
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Macro for concatenating two strings in C How to concatenate two strings with a macro? I tried this but it does not give correct results: #define CONCAT(string) "start"##string##"end" 回答1: You need to omit the ## : adjacent string literals get concatenated automatically, so this macro is going to concatenate the strings the way you want: #define CONCAT(string) "start"string"end" For two strings: #define CONCAT(a,

multiple definition of a function

廉价感情. 提交于 2021-01-27 06:53:50
问题 I defined a function to show a message when debug flags are off in a header file as below: #ifdef NDEBUG #define debug_msg(expr, msg) (static_cast<void>(0)) #else /* Not NDEBUG. */ #ifndef SHOW_DEBUG_H_ #define SHOW_DEBUG_H_ #include <stdio.h> void _show_in_debug(const char *_file, unsigned int _line, const char *_function, const char *_msg) { printf("%s\t%d\t%s\t%s\n", _file, _line, _function, _msg); fflush(NULL); } #endif #define debug_msg(expr, msg) \ ((expr) \ ? _show_in_debug(__FILE__, _

What preprocessor symbols does Coverity define for a build using 'cov-build'?

萝らか妹 提交于 2021-01-27 06:26:12
问题 We use Coverity's Scan Build service for free and open source projects. I am working through two Coverity findings on tainted parameters ( TAINTED_SCALAR ). The taint is a false positive, so I am trying to instrument the code with Coverity's __coverity_tainted_data_sanitize__ to clear the issue. I want to guard the code that needs to use __coverity_tainted_data_sanitize__ because the function is only used with analysis builds using Coverity's cov-build tool. That is, I want to do something

How to check __builtin_ function is available on gcc

懵懂的女人 提交于 2021-01-27 05:21:14
问题 I need to know is there a method for gcc to check presence of those awesome __builtin_MY_DESIRED_FUNCTIONs For example, I'd like to use __builtin_nan and be sure it is available for my program and it won't fail during compilation time. I'll be more specific: on clang there is __has_builtin "checker" so we can write smth like #if __has_builtin(__builtin_nan) But I can't find analog for gcc. And probably I can rely just on gcc, like "Oh, I'm on gcc now, just let's assume all of those __builtin_

How to check __builtin_ function is available on gcc

非 Y 不嫁゛ 提交于 2021-01-27 05:20:50
问题 I need to know is there a method for gcc to check presence of those awesome __builtin_MY_DESIRED_FUNCTIONs For example, I'd like to use __builtin_nan and be sure it is available for my program and it won't fail during compilation time. I'll be more specific: on clang there is __has_builtin "checker" so we can write smth like #if __has_builtin(__builtin_nan) But I can't find analog for gcc. And probably I can rely just on gcc, like "Oh, I'm on gcc now, just let's assume all of those __builtin_

How to define UNICODE for mingw, if use CMAKE as building system

北城以北 提交于 2021-01-22 12:04:04
问题 Good day, i build my Qt project with Cmake build system on windows platform, but if i add line in cmake file: add_definitions("-DUNICODE -D_UNICODE") definition of UNICODE not working(MINGW), this work properly only if i build my project with MSVC compiler. After some times i found workaround How do I define a variable when I call CMake, so that qtcreator knows it is defined?, this solution work but if i use native WINAPI functions such as CreateFile i get the compile error, because compiler

How to define UNICODE for mingw, if use CMAKE as building system

六月ゝ 毕业季﹏ 提交于 2021-01-22 12:01:37
问题 Good day, i build my Qt project with Cmake build system on windows platform, but if i add line in cmake file: add_definitions("-DUNICODE -D_UNICODE") definition of UNICODE not working(MINGW), this work properly only if i build my project with MSVC compiler. After some times i found workaround How do I define a variable when I call CMake, so that qtcreator knows it is defined?, this solution work but if i use native WINAPI functions such as CreateFile i get the compile error, because compiler

How to define UNICODE for mingw, if use CMAKE as building system

…衆ロ難τιáo~ 提交于 2021-01-22 12:00:27
问题 Good day, i build my Qt project with Cmake build system on windows platform, but if i add line in cmake file: add_definitions("-DUNICODE -D_UNICODE") definition of UNICODE not working(MINGW), this work properly only if i build my project with MSVC compiler. After some times i found workaround How do I define a variable when I call CMake, so that qtcreator knows it is defined?, this solution work but if i use native WINAPI functions such as CreateFile i get the compile error, because compiler

How to define UNICODE for mingw, if use CMAKE as building system

╄→尐↘猪︶ㄣ 提交于 2021-01-22 11:57:50
问题 Good day, i build my Qt project with Cmake build system on windows platform, but if i add line in cmake file: add_definitions("-DUNICODE -D_UNICODE") definition of UNICODE not working(MINGW), this work properly only if i build my project with MSVC compiler. After some times i found workaround How do I define a variable when I call CMake, so that qtcreator knows it is defined?, this solution work but if i use native WINAPI functions such as CreateFile i get the compile error, because compiler

Can any one explain about X-macros with example code to use them? [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-19 09:05:02
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 7 years ago . Improve this question I am trying to understand the X-macros topic in detail. But didn't get the full clarity on this. It would be better if any one of the expert will explain this topic with some example "how to use, how to call." I have found several articles, but didn't get the