[...]
Yur're right, I wrote wrong the macro expansion.
What I want is that when I compile this source under linux the macro is
translated into the pthread_create(...) function, knowing that the macro
has only two parameters. My problem is that I don't know how to create
dinamically a func_id to be inserted into the macro definition.
You'd need to generate both the declaration and the use:
#define THREAD(func,parm) { \
pthread_t func ## _id; \
pthread_create(&func ## _id, NULL, func, (void*)(parm)); \
}
Under C99 or later, which allow variable declarations to be
intermixed with executable statements, you can get rid of the
curly braces.
<off-topic>
... but it's a dumb idea. The pthread_t variable is your only
"handle" for the new thread, something you'll need if you later
want to await the thread's completion or send it a signal or anything
of that kind. It's a vital part of the machinery, not something that
should be swept under the rug.
Also, the presence of the declaration means that the macro
expansion is no longer an expression (it's a declaration plus an
expression-statement, possibly wrapped in a compound statement).
Since it's not an expression it has no value, meaning that the value
returned by pthread_create() is simply lost: You have no way of
knowing whether thread creation succeeded or failed, and no clue
as to the cause of a failure.
Why do you think such a macro would be desirable?
</off-topic>