typedef v macro

U

Uno

Hello ng,

I hope this message finds you all well. It's been a while since I've
had any real time to devote to programming and usenet, and while I'll
hope to stay busy as a handyman through the winter, I'll take it as the
silver lining that I can pursue avocation and hobby otherwise.

Keith posted this source in comp.std.c:

$ gcc -Wall -Wextra e2.c -o out
$ ./out
float_t is not a macro
$ cat e2.c
#include <math.h>
#include <stdio.h>
int main(void)
{
#ifdef float_t
puts("float_t is a macro");
#else
puts("float_t is not a macro");
#endif
return 0;
}
// gcc -Wall -Wextra e2.c -o out
$

1) I'm looking for general comments on the above. including whether you
get different output.

2) Can a conforming implementation render the other possibility?

Thanks for your comment,
and cheers,
 
K

Keith Thompson

Uno said:
I hope this message finds you all well. It's been a while since I've
had any real time to devote to programming and usenet, and while I'll
hope to stay busy as a handyman through the winter, I'll take it as the
silver lining that I can pursue avocation and hobby otherwise.

Keith posted this source in comp.std.c:

$ gcc -Wall -Wextra e2.c -o out
$ ./out
float_t is not a macro
$ cat e2.c
#include <math.h>
#include <stdio.h>
int main(void)
{
#ifdef float_t
puts("float_t is a macro");
#else
puts("float_t is not a macro");
#endif
return 0;
}
// gcc -Wall -Wextra e2.c -o out
$

1) I'm looking for general comments on the above. including whether you
get different output.

2) Can a conforming implementation render the other possibility?

If you wanted to discuss this, surely it would have made more
sense to post a followup in comp.std.c rather than starting a new
thread here in comp.lang.c. You could at least have refered to,
or even quoted, the argument I made there that float_t *cannot*
be a macro in a conforming implementation.

I believe the following program is strictly conforming:

#include <math.h>
int main(void) {
int float_t;
return 0;
}

If float_t were a macro usable as a type name, it would fail
to compile.

I do think the Standard would be slighly clearer if it stated
explicitly that the types defined in the various standard headers
are typedefs.
 
U

Uno

Keith said:
If you wanted to discuss this, surely it would have made more
sense to post a followup in comp.std.c rather than starting a new
thread here in comp.lang.c. You could at least have refered to,
or even quoted, the argument I made there that float_t *cannot*
be a macro in a conforming implementation.

No, I made the right decision to start a new thread, for a variety of
reasons, and since humor and honoring the recently-departed is always on
topic in clc, my name's not Shirley.

I thought the previous thread very successful in solving many of the
problems with floating point, if only because, when exposed to a larger
audience, they didn't seem to be problems so much as challenges.

Also, crossposted stuff needs to have an expiration date, or heterodoxy
devolves into a flamy thing. I hardly remember all of the context by
now, but I knew that next time I got on usenet, I wanted to feed your
source to gcc and pick up there.
I believe the following program is strictly conforming:

#include <math.h>
int main(void) {
int float_t;
return 0;
}

If float_t were a macro usable as a type name, it would fail
to compile.

Ok. No one seems to object. Can one imitate a typedef with a macro as
a useful, non-standard hack?
I do think the Standard would be slighly clearer if it stated
explicitly that the types defined in the various standard headers
are typedefs.

Can you give other examples here?
 
K

Keith Thompson

Uno said:
Keith said:
Uno said:
I hope this message finds you all well. It's been a while since I've
had any real time to devote to programming and usenet, and while I'll
hope to stay busy as a handyman through the winter, I'll take it as the
silver lining that I can pursue avocation and hobby otherwise.

Keith posted this source in comp.std.c:
[snip]
If you wanted to discuss this, surely it would have made more
sense to post a followup in comp.std.c rather than starting a new
thread here in comp.lang.c. You could at least have refered to,
or even quoted, the argument I made there that float_t *cannot*
be a macro in a conforming implementation.

No, I made the right decision to start a new thread, for a variety of
reasons, and since humor and honoring the recently-departed is always on
topic in clc, my name's not Shirley.

Yes, Mr. Nielsen will indeed be missed.

As for starting a new thread being "the right decision", I'm at a
loss to follow your reasoning. And again, you snipped the part of
the article you quoted in which I answered the very question you
were asking.

[...]
Can you give other examples here?

Probably.
 

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

Similar Threads

APPLYXn: variadic X-Macro 0
L in return 23
faq 19.1 57
Macro NULL or 0 5
Crazy macro-based doubly-linked list... 7
when to ignore warnings 1
Array implementation of Stack 80
Endianness macros 48

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top