What is C header file sys/cdefs.h used for?

L

lauren

I've found this in some source file and have no idea what it is used
for. And help?
 
L

lauren

Kenny said:
I've found this in some source file and have no idea what it is used
for. And help?

(hah hah hah - beat you to it, Keith [and others])

Off topic. Not portable. Cant discuss it here. Blah, blah, blah.

Of course I know this is not "that" portable but this is a component of
glibc and surely portable at least among Linux world. Standard C has
only 24 header files and we surely need to learn others :)
 
J

James Kuyper

lauren said:
Kenny said:
I've found this in some source file and have no idea what it is used
for. And help?

(hah hah hah - beat you to it, Keith [and others])

Off topic. Not portable. Cant discuss it here. Blah, blah, blah.

Of course I know this is not "that" portable but this is a component of
glibc and surely portable at least among Linux world. Standard C has
only 24 header files and we surely need to learn others :)

True, but the appropriate place to discuss those other headers is a
forum devoted specifically to the kind of systems where those headers
are present. A quick look at the file suggests that it may be
gcc-specific, so look for a gcc forum.
 
R

Richard

James Kuyper said:
lauren said:
Kenny said:
I've found this in some source file and have no idea what it is
used for. And help?

(hah hah hah - beat you to it, Keith [and others])

Off topic. Not portable. Cant discuss it here. Blah, blah, blah.

Of course I know this is not "that" portable but this is a component
of glibc and surely portable at least among Linux world. Standard C
has only 24 header files and we surely need to learn others :)

True, but the appropriate place to discuss those other headers is a
forum devoted specifically to the kind of systems where those headers
are present. A quick look at the file suggests that it may be
gcc-specific, so look for a gcc forum.

The contents are, however, C.

.....
 
R

Richard

Anthony Fremont said:
James said:
lauren said:
Kenny McCormack wrote:
I've found this in some source file and have no idea what it is
used for. And help?

(hah hah hah - beat you to it, Keith [and others])

Off topic. Not portable. Cant discuss it here. Blah, blah, blah.


Of course I know this is not "that" portable but this is a component
of glibc and surely portable at least among Linux world. Standard C
has only 24 header files and we surely need to learn others :)

True, but the appropriate place to discuss those other headers is a
forum devoted specifically to the kind of systems where those headers
are present. A quick look at the file suggests that it may be
gcc-specific, so look for a gcc forum.

What file did you review, the OP didn't identify the environment at all. I
think you'll find a "sys/cdefs.h" on plenty of systems that don't use gcc.

Whereupon the usual wannabes will use this as an example of why not to
ask here ...

Their correct response was "tell us more about the file and the
contents" since there is nothing there that might, as yet, preclude it
from really being Ansi C and he just needs help understanding the
contents.
 
S

Steffen Buehler

Anthony Fremont wrote:

[sys/cdefs.h]
It looks like "glue" to me. Just something to help some real-world
source code get along with real-world compilers and real-world
environments.

Indeed so. An cute excerpt of a cdefs.h I have here:

<snip>
/*
* GCC 2.95 provides `__restrict' as an extention to C90 to
* support the C99-specific `restrict' type qualifier. We
* happen to use `__restrict' as a way to define the `restrict'
* type qualifier without disturbing older software that is
* unaware of C99 keywords.
*/
#if !((defined(__GNUC__) && __GNUC__ == 2) && __GNUC_MINOR__ == 95)
#if !defined(__STDC_VERSION__) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901)
#define __restrict
#else
#define __restrict restrict
#endif
#endif
<snip>

Regards
Steffen
 
V

vippstar

An cute excerpt of a cdefs.h I have here:

<snip>
/*
 * GCC 2.95 provides `__restrict' as an extention to C90 to
 * support the C99-specific `restrict' type qualifier.  We
 * happen to use `__restrict' as a way to define the `restrict'
 * type qualifier without disturbing older software that is
 * unaware of C99 keywords.
 */
#if !((defined(__GNUC__) && __GNUC__ == 2) && __GNUC_MINOR__ == 95)
#if !defined(__STDC_VERSION__) || \
    (defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901)
#define __restrict

redundant, fix:

#if !((defined(__GNUC__) && __GNUC__ == 2) && __GNUC_MINOR__ == 95)
#if !defined(__STD_VERSION__) || __STDC_VERSION < 199901
#define __restrict
 
R

Richard

Han from China - Master Troll said:
Richard said:

Probably why the one-time poster "lauren" is asking it in the first
place.


Ouch. That's a pedant smackdown right there and will be used in the
next version of my topicality FAQ.

Since ANSI/ISO C doesn't define a sys/cdefs.h header, the pedants
can't say that a custom sys/cdefs.h header is off-topic, since
by their own bizarre reasoning, they're not allowed to take guesses
at the contents of sys/cdefs.h based on non-ANSI/ISO C experiences.
So if someone asks about windows.h, the appropriate response will
be "please tell us more about the file and/or post the contents",
since ANSI/ISO C doesn't forbid a custom windows.h header.

This has pretty much always been my stance. How can we know until we see
the contents?

Many OSen and Window Managers have "windows" but they are nothing to do
with Microsoft for example. It does not stretch ones imagination to
believe that many people have implemented things called "windows.h".
 
V

vippstar

Whether this newsgroup is strictly for ANSI/ISO C
is a matter of opinion, since this newsgroup has no charter and, in fact,
has a founding message that predates ANSI/ISO C.

This got me into some thinking. Is the troll lying about this? Or
comp.lang.c is indeed older than the ANSI C standard? In which case,
since when it was decided that the topicallity of comp.lang.c is K&R
C, ANSI/ISO C?

It's not that I disagree with such topicallity, I'm just curious for
some comp.lang.c history...
 
R

Richard

This got me into some thinking. Is the troll lying about this? Or
comp.lang.c is indeed older than the ANSI C standard? In which case,
since when it was decided that the topicallity of comp.lang.c is K&R
C, ANSI/ISO C?

It's not that I disagree with such topicallity, I'm just curious for
some comp.lang.c history...

There is no charter saying "ISO C". End of subject. The groups name is
comp.lang.c, similar its counterparts its for the discussion of the C
language.

A small clique tried limiting the topicality to things which only
interested them.
 
K

Kenny McCormack

Richard said:
The contents are, however, C.

Not according to the regulars here.

It is, in their view, clearly not C. It could pumpkin squash, for all
they care. But it is not C.
 
R

Richard

Anthony Fremont said:
Why would you intentionally obfuscate your response like that? Does Han
from China have a habit of posting incorrect information? I hadn't noticed
him misleading anyone at any time; I may have missed it though.

Heathfield acts like a junk yard dog if he thinks someone is pissing on
his patch. Like a lot of religious nuts he thinks there is only one
right way and that's his way. Personally I find Hans knowledge very
welcome and certainly more so than the blinkered nonsense from a good
proportion of the regs.
 
R

Richard

Comp.lang.c is the renamed net.lang.c (renamed during the great
renaming). The original groups did not have charters. As part
of the reorganization during the great renaming a process was
established for creating new groups; this process included having
a charter. I have contributed to the news group off and on since
1983 but it goes back a bit further than that. (The usenet news
system started in 1979.)

What constitutes topicality is a communal decision, that by not
means is agreed to by everyone. In the beginning, insofar as
people worried about the issue, topicality was "the issues
involved in programming in C". That is the nature of topicality
in many programming language groups. IMACO that is what it
should be.

At some time in the last dozen years a group of people insisted
that the newsgroup was strictly for standard C (K&R, 89 and 99).
I wasn't posting in comp.lang.c when the revolution occurred;
perhaps one of the current regulars will admit to the details.
Judging from the current state of the group, the style of the
revolutionaries was aggressive, arrogant, and dogmatic.

Be that as it may, actual topicality is whatever the group is
willing to discuss. You can discuss pretty much anything you
want to provided that you don't phrase it in a way that tickles
the delicate antennae of the self-appointed topicality monitors.

Very well said and much more political then anything I could now be
bothered to muster in order to counter the self righteous, pompous
garbage from the select few.
 
J

jameskuyper

Anthony said:
James Kuyper wrote: ....

What file did you review, the OP didn't identify the environment at all. I
think you'll find a "sys/cdefs.h" on plenty of systems that don't use gcc.

As I said, it was "a quick look"; specifically, a quick look at the
file with that name in that directory on my home computer. The only
conclusion I reached was that "it may be gcc-specific"; I had no
inclination to dig into it further. I wouldn't be the least bit
surprised to find out that it wasn't gcc-specific.
 
K

Keith Thompson

Anthony Fremont said:
Why would you intentionally obfuscate your response like that? Does Han
from China have a habit of posting incorrect information?

Yes, including blatantly forged messages.
 
K

Kenny McCormack

Richard said:
There is no charter saying "ISO C". End of subject. The groups name is
comp.lang.c, similar its counterparts its for the discussion of the C
language.

Quite so. In fact, at one point in the whacky history of clc, the regs
were the ones bashing home the notion that "there is no charter". At
that time, it served their purposes to say so. Now the shoe is on the
other foot.
A small clique tried limiting the topicality to things which only
interested them.

It is actually a little more complicated than that.

I don't think it is really "what interests them" as much as a paranoid
hatred and fear of, yes, you guessed it, Microsoft. When it became
clear (in the early 90s) that MS was, indeed, going to rule the world,
the old fogies in this NG realized (quite correctly, mind you) that
their precious newsgroup was about to get over-run with Windows
questions (you know, the usual lpThis lpThat DllImport DllSpec, blah,
blah, stuff). Well, the obvious solution to this was to invent from
whole cloth the notion that C was that which was in the standard and
nothing more. Take that, and throw in a cadre of like-minded, Christian
religious nutcases (a lot of the same nutty fundiness that has been
running the US [and Britain] for past 8+ years) and you've got a great
formula for squelching discussion of programming on the world's premier
operating systems.

Now, fairness does require (*) that if you're going to take this
position, you have to ban all OS's, not just the one in your sights.
So, hence the need to ban Unix as well, despite the fact that they all
love Unix. But you will notice that discussion of Unix does creep in
from time to time and is not usually dealt with that severely.
Everybody understands that discussion of Unix stuff is
wink-wink-nudge-nudge stuff as compared with discussion of the spawn of
Billy.

(*) I should also add that it isn't really fairness per se; that's just
a nice way of putting it. It is that if they didn't offer at least
token resistance to Unix stuff, the newbies would see right through it,
and we'd have had the inevitable revolt (that which we are seeing now,
thanks in large part to my good friend Han) much earlier.
 
K

Kenny McCormack

Kenny said:
I've found this in some source file and have no idea what it is used
for. And help?

(hah hah hah - beat you to it, Keith [and others])

Off topic. Not portable. Cant discuss it here. Blah, blah, blah.

Of course I know this is not "that" portable but this is a component of
glibc and surely portable at least among Linux world. Standard C has
only 24 header files and we surely need to learn others :)

Stick around. You'll learn.
 
F

Flash Gordon

Han said:
Lauren wrote:

In this case, the one-time poster lauren is actually Flash Gordon (watch
for those silent ignores on this point, folks!), but since we won't

<snip>

This is, of course, plain and simple lying on the part of Han.
 
Q

qarnos

This got me into some thinking. Is the troll lying about this? Or
comp.lang.c is indeed older than the ANSI C standard? In which case,
since when it was decided that the topicallity of comp.lang.c is K&R
C, ANSI/ISO C?

It's not that I disagree with such topicallity, I'm just curious for
some comp.lang.c history...

For the record, here is a link to the Google archive of the first
message in net.lang.c (The former comp.lang.c, as Richard Harter
points out further downthread):

http://tinyurl.com/9zfzkw
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top