macro question

A

abir

Hi,
this is not related to strict c++ , but macro.
I want a statement to be generated like
std::size_t count = sizeof(trace2)/sizeof(coord_t);
for (std::size_t i = 0; i< count; i += 2){
std::cout<<trace2<<" "<<trace2[i+1]<<std::endl;
}

when i write LOAD_TOKEN(2)

so the main problem is to essentially catenate "token" with a token
id.
I am looking at ##, but in between something fails to compile.
thanks
abir
 
T

Tom

Hi,
so the main problem is to essentially catenate "token" with a token
id.
I am looking at ##, but in between something fails to compile.
Usually it works like this:

#define LOAD_TOKEN(n) ....token##n....

where "..." has to be your code, of course.

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,176
Messages
2,570,947
Members
47,501
Latest member
Ledmyplace

Latest Threads

Top