Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Pre-processor define after class keyword and before class name

I recently came across this sort of code in someone's opengl shader class and am not sure of its use.

As I understand it from reading IBM's documentation, the #define ONEWORD will remove any occurence of ONEWORD in the subsequent text.

What is the purpose of having ONEWORD in this code at all if all occurrences are removed? What does having a token like that, after a class keyword but before a class name, really mean?
I've only used #define for include guards in the past so this is entirely new for me.

#define ONEWORD

class ONEWORD FooClass
{
    FooClass();
    ~FooClass();
};

The code I saw this in is here: https://dl.dropbox.com/u/104992465/glsl.h
Just in case I've made its context too abstract.

like image 884
Katawa Tenshu Avatar asked Apr 04 '13 06:04

Katawa Tenshu


1 Answers

It's to allow you to easily add compiler specific keywords to your class declaration. For instance with Visual Studio, if you wanted to put this class in a DLL, you would change your definition to

#define ONEWORD __declspec( dllexport )

See here for another example

like image 151
john Avatar answered Sep 27 '22 15:09

john