Your opinion

K

Keith Thompson

Actually no. THis has nothing to do with the macros. In your code " B ;"
doesn't make sense. B has no type and is hence undefined. So when it is
replaced by A, it is still undefined.

The point, I think is that the compiler's error message, "Undefined
symbol 'B'" or "Undefined symbol 'A'", tells you what the symbol B was
ultimately replaced with by the preprocessor. Presumably the part of
the compiler that complains about undefined symbols runs after the
preprocessor (and doesn't have any visibility to the un-preprocessed
source).

It's an odd way of figuring out what the preprocessor is doing, but it
works in this case.
 
M

Micah Cowan

Ben Pfaff said:
I don't think that this code is undefined in C99. Check out
example 3 in C99 6.7.3.1:

printf() doesn't modify its arguments[1] so I don't think that
printf("%s", "%s"); is undefined.

Or am I missing something?

[1] Well, certainly not in this case, unless you want to argue
that one should not pass string literals to printf().

Yeah, okay, that sounds right. In that case, Dan, what *was* the
issue? Or were you thinking the same way? Or was the "restrict issue"
the misdeclaration of printf()?

-Micah
 
D

Dan Pop

In said:
Yeah, okay, that sounds right. In that case, Dan, what *was* the
issue? Or were you thinking the same way? Or was the "restrict issue"
the misdeclaration of printf()?

The latter. It's trivial to fix by defining restrict as an empty macro
if the compiler doesn't claim C99 conformance and using the proper C99
prototype for printf.

Dan
 
D

Dan Pop

Back when I used it, some 13 years ago, it came with a separate utility
that was performing only the preprocessing. It was meant to help
in such cases.
Or you can also tell me how it can be done on a Linux machine with all
standard development tools installed.

Ever considered reading the gcc man page?

-E Stop after the preprocessing stage; do not run the
compiler proper. The output is preprocessed source
code, which is sent to the standard output.

Dan
 
P

Peter Shaggy Haywood

Groovy hepcat Steve Zimmerman was jivin' on Mon, 22 Sep 2003 19:57:54
GMT in comp.lang.c.
Re: Your opinion's a cool scene! Dig it!
Thank you for this post, Ravi.

Output: 5 6.000000 0 0.000000
(There is one space before the 5.)

I don't know if it's implementation dependent.

If you don't know, why say anithing?
The code that you cite from the technical skill paper is referred to
as "spaghetti code" by _The New Hacker's Dictionary_. Spaghetti code
is code with an unnecessarily complex and tangled control structure.

Nonsense! This program has a very short and absolutely linear flow,
one statement after another - literally.
 
P

Peter Nilsson

Ben Pfaff said:
Pointless and stupid and effectively a no-op besides.


You should declare main() as explicitly returning `int'. This is
required in C99. You should also write `void' within the
parentheses to give it a prototype, though it is not required.


You should return a value from main().


It is undefined for at least two reasons: first, trying to print
out an `int' using %f; second, for failing to write a final
new-line character to stdout.

The last omission merely invokes implementation defined behaviour.

[The standard means to say that in order to be a line, an implementation may
require the presense of a trailing \n, otherwise it will be ignored.
Unfortunately, C99 has a much worse situation of UB in the guise of IDB,
namely in the potential signal raised in conversions to signed integers.]
^^^^^^^^^
Quite probably!
I think it aims at testing something, but it has little to do
with C skills, especially considering the stupid macro
definitions. It tests knowledge of C trivia, not knowledge of C
usage.

I'd be asking if it was a typical example of the companies code... ;)
 
J

Joona I Palaste

Few non-native English speakers are likely to get this one.

I got it and I'm a non-native English speaker. What do I win?

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"A friend of mine is into Voodoo Acupuncture. You don't have to go into her
office. You'll just be walking down the street and... ohh, that's much better!"
- Stephen Wright
 
B

Barry Schwarz

I got it and I'm a non-native English speaker. What do I win?

Obviously you get to be declared (or is it defined) one of the few.
And if you watch American TV commercials that makes you one of the
brave and proud.


<<Remove the del for email>>
 

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
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top