468,467 Members | 2,671 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,467 developers. It's quick & easy.

thread.h is name pollution ?


Hi All,

Just illustrating my lack of C knowledge again:

Wot now ? cat test.c
#include <pthread.h>

void thread_init( void ){}

Wot now ? xlc_r -c -qlanglvl=stdc89 test.c
"test.c", line 3.6: 1506-343 (S) Redeclaration of thread_init differs from previous declaration on line 886 of "/usr/include/sys/thread.h".
"test.c", line 3.6: 1506-376 (I) Redeclaration of thread_init has a different number of fixed parameters than the previous declaration.
Wot now ? xlc_r -c -qlanglvl=stdc99 test.c
"test.c", line 3.6: 1506-343 (S) Redeclaration of thread_init differs from previous declaration on line 886 of "/usr/include/sys/thread.h".
"test.c", line 3.6: 1506-376 (I) Redeclaration of thread_init has a different number of fixed parameters than the previous declaration.

In sys/thread.h thread_init is declared as

void thread_init(unsigned long long, unsigned long long)

and the -qlanglvl flags above ask the compiler to at least report deviations
from the c89 and c99 standards respectively.

Is the implementation allowed by the standard to reserve this part of the namespace ?

Ian

Jul 13 '06 #1
4 2474
Ian Bush wrote:
>
Hi All,

Just illustrating my lack of C knowledge again:

Wot now ? cat test.c
#include <pthread.h>

void thread_init( void ){}

Wot now ? xlc_r -c -qlanglvl=stdc89 test.c
"test.c", line 3.6: 1506-343 (S) Redeclaration of thread_init differs from previous declaration on line 886 of "/usr/include/sys/thread.h".
"test.c", line 3.6: 1506-376 (I) Redeclaration of thread_init has a different number of fixed parameters than the previous declaration.
Wot now ? xlc_r -c -qlanglvl=stdc99 test.c
"test.c", line 3.6: 1506-343 (S) Redeclaration of thread_init differs from previous declaration on line 886 of "/usr/include/sys/thread.h".
"test.c", line 3.6: 1506-376 (I) Redeclaration of thread_init has a different number of fixed parameters than the previous declaration.

In sys/thread.h thread_init is declared as

void thread_init(unsigned long long, unsigned long long)

and the -qlanglvl flags above ask the compiler to at least report deviations
from the c89 and c99 standards respectively.

Is the implementation allowed by the standard to reserve this part of the namespace ?
You've included a non-standard header; the (C) standard doesn't prohibit non-standard
headers from eating names that the standard headers don't eat.

I see your compiler doesn't remark on the non-standardness of <pthread.h>.

--
Chris "I'm sure some do: the Norcroft compiler?" Dollin
"Who do you serve, and who do you trust?" /Crusade/

Jul 13 '06 #2
Ian Bush said:
>
Hi All,

Just illustrating my lack of C knowledge again:

Wot now ? cat test.c
#include <pthread.h>

void thread_init( void ){}

Wot now ? xlc_r -c -qlanglvl=stdc89 test.c
"test.c", line 3.6: 1506-343 (S) Redeclaration of thread_init differs from
previous declaration on line 886 of "/usr/include/sys/thread.h". "test.c",
<snip>
>
In sys/thread.h thread_init is declared as

void thread_init(unsigned long long, unsigned long long)

and the -qlanglvl flags above ask the compiler to at least report
deviations from the c89 and c99 standards respectively.

Is the implementation allowed by the standard to reserve this part of the
namespace ?
No, unless you invite it to do so, by - for example - including a
non-standard header such as <pthread.h>.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 13 '06 #3

Richard Heathfield wrote:
Ian Bush said:
>>
Is the implementation allowed by the standard to reserve this part of the
namespace ?

No, unless you invite it to do so, by - for example - including a
non-standard header such as <pthread.h>.
Yeah, thanks Richard and Chris I should have realized that myself.

I'll have to see what pthreads says now,

Ian

Jul 13 '06 #4

Ian Bush wrote:
Richard Heathfield wrote:
Ian Bush said:
>
Is the implementation allowed by the standard to reserve this part of the
namespace ?
No, unless you invite it to do so, by - for example - including a
non-standard header such as <pthread.h>.

Yeah, thanks Richard and Chris I should have realized that myself.

I'll have to see what pthreads says now,
Of course it may be worth pointing out that functions like
"thread_init" are about as descript as

void function(...)

If the thread has a purpose [say spooling to printer] call it

int spool_thread_init(...) { }

Tom

Jul 13 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

31 posts views Thread by AlexeiOst | last post: by
2 posts views Thread by Birt | last post: by
37 posts views Thread by hasadh | last post: by
4 posts views Thread by Leonardo Hyppolito | last post: by
7 posts views Thread by Ivan | last post: by
13 posts views Thread by Bob Day | last post: by
5 posts views Thread by Mark R. Dawson | last post: by
2 posts views Thread by Eric S. Johansson | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.