Using the ## preprocessing operator fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux