macros


c preprocessor - Why is this macro replaced as 20 instead 10?

The text replacement is done where the macro is used, not where you wrote the #define. At the point you use FOO, it replaces FOO with NUM and NUM is currently defined to be 20.... Read More


Is there a __CLASS__ macro in C++?

The problem with using typeid(*this).name() is that there is no this pointer in a static method call. The macro __PRETTY_FUNCTION__ reports a class name in static functions as well as method calls. H... Read More


python - *args, **kwargs in jinja2 macros

The trick is that kwargs has to be accessed at least once in any macro that should accept them. That is to say, you must call {{ kwargs }} once in macro body without declaring it in macro argument li... Read More


c - What are the implications of the linux __user macro?

It allows tools like sparse to tell kernel developers that they're possibly using an untrusted pointer (or a pointer that may be invalid in the current virtual address mapping) improperly.... Read More


c++ - What does "#pragma comment" mean?

#pragma comment is a compiler directive which indicates Visual C++ to leave a comment in the generated object file. The comment can then be read by the linker when it processes object files. #pragma... Read More


c++ - How to identify platform/compiler from preprocessor macros?

For Mac OS : #ifdef __APPLE__ For MingW on Windows: #ifdef __MINGW32__ For Linux : #ifdef __linux__ For other Windows compilers, check this thread and this for several other compilers and architectur... Read More


iOS How to detect iPhone X, iPhone 6 plus, iPhone 6, iPhone 5, iPhone 4 by macro?

Swift import UIKit public enum DisplayType { case unknown case iphone4 case iphone5 case iphone6 case iphone6plus static let iphone7 = iphone6 static let iphone7plus = ip... Read More


Vim Macro on Every Line of Visual Selection

Suppose you had a macro q that ran (and remained) on a single line. Then you could run it on every line in your selection with: :'<,'>normal @q (if you already have a group of lines selected, hitting... Read More


c - What predefined macro can I use to detect clang?

To get a list of all the predefined macros that the compiler uses, use this: clang -dM -E -x c /dev/null You can do the same for gcc.... Read More


How to pass macro definition from "make" command line arguments (-D) to C source code?

Call make command this way: make CFLAGS=-Dvar=42 And be sure to use $(CFLAGS) in your compile command in the Makefile. As @jørgensen mentioned , putting the variable assignment after the make command... Read More