Posted By

jimfred on 12/03/08


c operator concatenation

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


C #define macro to generate a comment using concatenation operator in preprocessor

 / Published in: C


This uses the concatenation operator "##" to insert a comment "//"

  1. #define _AT_ ;/ ## /

Report this snippet  


RSS Icon Subscribe to comments
Posted By: pmkenny1234 on November 10, 2010

WARNING: We used this snippet to comment out some stream processing code in our application:

define FOO ;/ ## /


// somewhere in our code FOO

Posted By: pmkenny1234 on November 10, 2010

OK. It looks like I can neither edit my comment or delete it. Anyway, the point of the comment was that this code does NOT work on Linux or Mac. The // type of comment is a preprocessor directive and the preprocessor doesn't do multiple passes. We were commenting stream operators, so creating a dummy class with empty inlined stream operators and replacing the AT with those values worked fine and the compiler optimized out the useless code. Hope this helps someone.

Posted By: jaffa on June 19, 2012

A web development company can be run from your home, or you could lease a small office. Decide if you will have permanent employees or use freelancers for each job, and choose your location according to what fits your business model best. Thanks for sharing information. Regards, Resume help

You need to login to post a comment.