|
In general, I occasionally have a chain of nested macros with a few preprocessor conditional elements in their definitions. These can be painful to debug since it's hard to directly see the actual code being executed.
A while ago I vaguely remember finding...
Started by Tyler on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
This might not be applicable in your situation, but macros really do hamper debugging and often all together?
You should probably....
Debug the dissasembly with the symbols loaded.
Gcc -E will output the preprocessed source to stdout.
|
|
What is the standard macro used to write text to the output window in Win32 (outside MFC)? I am looking for something which the pre-processor conditionally excludes from the release build.
(This might sound like SO sacrilege but I've merely forgotten ...
Started by Agnel Kurian on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Maybe you're thinking of ATLTRACE? Not quite "the standard macro", but pretty close for this, which is a debug....
There is a trace macro macros a try.
It'll send output to the debug channel.
OutputDebugString(char*).
|
|
I know that JavaScript doesn't support macros (Lisp-style ones) but I was wondering if anyone had a solution to maybe simulate macros? I Googled it, and one of the solutions suggested using eval(), but as he said, would be quite costly.
They don't really...
Started by Anders Rune Jensen on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
That'll give you macros....
Most of the JavaScript: var a, b, c, d; d = c = b = a;
Several methods in jQuery are all essentially macros, although you .
Is to use functions, shorthand and ternary conditions as a replacement for macros.
|
Ask your Facebook Friends
|
What is the worst real-world macros/pre-processor abuse you've ever come across (please no contrived IOCCC answers *haha*)?
Please add a short snippet or story if it is really entertaining. The goal is to teach something instead of always telling people...
Started by Trevor Boyd Smith on
, 59 posts
by 54 people.
Answer Snippets (Read the full thread at stackoverflow):
MrValdez is annoyed by the GetObject macro found(-1); \ } \
I was pretty new to the practice of using macros and used this macro, but I expected to load the correct Roster....
Windows.h has a lot of functions that abused macros.
|
|
Consider this (horrible, terrible, no good, very bad) code structure:
#define foo(x) // commented out debugging code // Misformatted to not obscure the point if (a) foo(a); bar(a);
I've seen two compilers' preprocessors generate different results on this...
Started by Novelocrat on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
In the C90 standard (which I only have in hard copy, so no copy-n and replaced by a single whitespace... .
Unfortunately, the original ANSI C and macros are expanded in phase 4.
Happens before the preprocessing phase where macros are expanded.
|
|
I'm trying to get a better understanding of what place (if any) Macros have in modern C++ and Visual C++, also with reference to Windows programming libraries: What problem (if any) do Macros solve in these situations that cannot be solved without using...
Started by Peter McGrattan on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Basically what....
Macros don't have muchAll of those Macros are defined in public sdk header files, so you can go read what they do yourself if you want.
Of boiler-plate up front but in exchange you make it much harder to debug later.
|
|
How can I replace all occurrence of user defined latex macros with their definitions?
For example, given this file
old.tex
\newcommand{\blah}[2]{#1 \to #2} ... foo \blah{egg}{spam} bar ...
how to generate the file below in an automatic way
new.tex
......
Started by RamyenHead on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
For example, your above code should work as expected as:
[% macro blah(eggNever seen this done, but 2 half-baked ideas:
If the reason why you want to expand all these macros inline is for debugging....
Jinja2 supports macros .
|
|
The C preprocessor is justifiably feared and shunned by the C++ community. In-lined functions, consts and templates are usually a safer and superior alternative to a #define .
The following macro:
#define SUCCEEDED(hr) ((HRESULT)(hr) >= 0)
is in no...
Started by Motti on
, 35 posts
by 32 people.
Answer Snippets (Read the full thread at stackoverflow):
Something....
Macros will always have their place.
Thus you can define a foreach macro:
#define foreach, i) printf("Cookie: %s", cookies[i]);
Compilers can refuse your request to inline.
Compilable code; macros may be code fragments.
|
|
I'd like to make a debug logging function with the same parameters as printf. But one that can be removed by the pre-processor during optimized builds.
For example:
Debug_Print("Warning: value %d > 3!\n", value);
I've looked at variadic macros but ...
Started by hyperlogic on
, 13 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
I still do it the old way, by defining a macro (XTRACE and C89 syntax for debug macros Enable/Disable output based on function argument Output to file that uses the ....
And the whole line will get removed in non-DEBUG code.
|
|
After reading another question about the use of macros, I wondered: What are they good for?
One thing I don't see replaced by any other language construct very soon is in diminishing the number of related words you need to type in the following:
void ...
Started by xtofl on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
};
compile different code under different conditions ( #ifdef __DEBUG: BEGIN_MESSAGE_MAP() ); See interesting macro....
The __FILE__ and __LINE__ macros, then another macro is by far the most convenient way to go MY_API MyClass { ...
|