Using the ## preprocessing operator fails

Ike Starnes ikestarnes@live.com
Fri Aug 26 14:54:00 GMT 2011


The following code builds fine in Microsoft C, but fails with gcc / g++:


#include <iostream>

using namespace std;

typedef struct _THREADDATA
{
   int nConvTiles;        // the number of swap buffers in a tiled bitmap
used for caching the disk tiles (default 1)
}
THREADDATA, *pTHREADDATA;

#define DECLARETHREADDATA() pTHREADDATA pThreadData = NULL;
#define GETTHREADDATA() pThreadData
#define THREADVALUE(v) GETTHREADDATA()->##v

static int GetTilesInfo()
{
   DECLARETHREADDATA();
   int nConvTiles;
   nConvTiles = THREADVALUE(nConvTiles);
   return nConvTiles;
}

int main()
{
    cout << "Hello world!" << endl;
    cout << GetTilesInfo();
    return 0;
}


With gcc, the error is:
d:\temp\GNU\HelloWorld\main.cpp:19:1: error: pasting "->" and "nConvTiles"
does not give a valid preprocessing token

Does anyone know the correct fix?
-- 
View this message in context: http://old.nabble.com/Using-the----preprocessing-operator-fails-tp32342472p32342472.html
Sent from the gcc - Help mailing list archive at Nabble.com.



More information about the Gcc-help mailing list