« The code is THE documentation | Main | Digital Misfortunes: Off-the-shelf end-user product mafia »

November 30, 2008

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341d80a253ef0105362cd145970c

Listed below are links to weblogs that reference Tips on writing C macros:

Comments

thanasisk

assuming that you are within a C++ enviroment, #define should be banned.

If you just wanna save a function call, why not make it an inline function?

If you just wanna have a constant variable, why not use const and get more info while debugging?

No corner cases please :)

thanasisk

Kai edw o antilogos :-)

http://lixtetrax.wordpress.com/2008/12/26/refuting-tips-on-writing-c-macros/

Ante, ti 8a ginei, pote 8a grapsoyme ligo C parea? ;)

foo

how can you *ever* step into macros? you cannot, macros are processed by preprocessor and the compiler doesnt even know about them. So the generated code (which you effectively debug) doesnt have a hint of macros.

rodrigo

@foo, the preprocessor could add file/linenumber directives (like the ones it puts when processing #includes), which the compiler can then embed into the object code.

Not saying it would be easy (otherwise all compilers would do it), but it's not impossible in principle.

Dimitris Staikos

The SoftICE debugger could step into macros :-)
Pity it is a dead product...

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment