473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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 2606
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: AlexeiOst | last post by:
Everywhere in documentation there are recommendations to use threads from thread pooling for relatively short tasks. As I understand, fetching a page or multiple pages (sometimes up to 50 but not...
2
by: Birt | last post by:
An article states: the global namespace be polluted, causing "a namespace collision." What does this mean exactly? Thank you very much!
37
by: hasadh | last post by:
Hello, probably this may be a simple qn to u all but I need an answer plz. In my software i used macros like OK,TRUE,FALSE,FAILURE . A friend who included this code as a library into his module...
4
by: Leonardo Hyppolito | last post by:
Hello, I am trying to write a multithread program that simulates producers and consumers. My program can have many producers and many consumers (each in a separate thread). It has a storage...
7
by: Ivan | last post by:
Hi I have following problem: I'm creating two threads who are performing some tasks. When one thread finished I would like to restart her again (e.g. new job). Following example demonstrates...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
5
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I...
2
by: Eric S. Johansson | last post by:
I have a collection of packages and I want to put them under single unifying name. my goal is to reduce namespace pollution and make all these packages accessible as 'import vvv.aaa'. In more...
1
by: Peter Duniho | last post by:
On Thu, 26 Jun 2008 03:35:58 -0700, DeveloperX <ianathomeagain@googlemail.comwrote: I think these articles are informative and useful food for thought. However, they don't seem to really be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.