By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,116 Members | 1,282 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,116 IT Pros & Developers. It's quick & easy.

thread.h is name pollution ?

P: n/a

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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a

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

P: n/a

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.