Compiler Pragmas We’d Like To See

#pragma expiration(date)

Refuse to compile the following code after the specified date.

#pragma moran(email address)

Emails the specified address every time there is a compilation error in any code that follows.

#pragma tricky

Tells the optimizer to go easy on the next bit.

#pragma borken

Tells the compiler to do its worst; it hardly matters, the code is busted anyway.

#pragma stfu

Tells the compiler to shut up and compile. That’s your job, and that’s it. Your job is not to announce banners about compiler versions, or display company logos in blinking text, or declare with amazement (and a full line of “!!!!!!!!!” marks) that the compilation has finished with 0 errors, 0 warnings, 0 flatulent events, and 0 animals harmed.

#pragma blame(username)

If there are errors in the following code, arrange with the source code control system to blame it on some other checkin made by the specified user.

#pragma whew

Dear reader, take a break, you have earned it.

#pragma notme

This design was someone else’s idea, not mine. Don’t blame me.

#pragma myway

If I were to do it, I’d write it this way. I feel like a total moron doing it that other way, but nobody listens and nobody appears to care. (Implementation-dependent side effect: The code is enabled when the project is cancelled).

Author: landon

My mom thinks I'm in high tech.

5 thoughts on “Compiler Pragmas We’d Like To See”

  1. Lol…funny and creative. I would like to add to the list when compiler can analyse the code and rate the programmers. For example:

    “You are better than Programmer B but worse than Programmer K.”

    That would be amusing!

  2. I think #pragma myway should be an if/else conditional, and hooked into the HR database. Which version gets compiled depends on who is still at the company. If both parties leave it automatically becomes a #error until someone else steps up.

  3. #pragma expiration(date) exists already, in the form of #if DATE_AS_INT(__DATE__) > … #error “I’m expired” #endif. Consult the comp.lang.c archives for the definition of the DATE_AS_INT macro.

    #pragma moran(address) can be done with a SVN hook, and usually is.

    #pragma stfu is of course equivalent to “>/dev/null”.

    No comment on the obvious joke entries.

  4. I actually do this on some projects: =)

    (if _MSC_VER is defined)
    #define STFU(x) warning(disable: x)

    Examples of use:

    #pragma STFU(4514) // unreferenced inline function removed
    #pragma STFU(4100) // unreferenced formal parameter

Leave a Reply to Sol_HSA Cancel reply

Your email address will not be published. Required fields are marked *