Randy said:
Eric Sosman said:
Randy said:
OK, I've changed the test. When I call SMFReport, the
first few lines of which are:
[...]
printf("here 0\n");
fprintf(stdout, "SMF Report of File \n");
printf("here 1\n");
I get this:
Bus Error (core dumped)
<yates_dsp-54_3.60> /vobs/annadsp_sw/midi/app/smf $ If I change the
fprintf to a printf:
[...]
printf("here 0\n");
printf("SMF Report of File \n");
printf("here 1\n");
it runs fine.
Let's see: calls to printf() work fine. Since printf()
writes to stdout, this shows that the stream is open and is
working correctly. Yet fprintf(stdout,...) fails. Hmmm ...
Is it possible that there's some chicanery in a header
file that has re-#defined the `stdout' identifier?
Yes, that was essentially my idea when I wrote in an adjacent post
that I might be using the include file for another target (like the
PC - I'm on a Sun).
But alas, gcc -E thefile.c indicates it's picking up stdio from the
right place. Or at least a sun directory. The thing I've noticed
now is that my configuration (it's complicated - I'm running
under clearcase with various tool versions mapped based on the
config spec) is selecting solaris 2.7 for the library includes
and we're using solaris 2.8. Would that cause such a
problem? Is there a different set of include files for solaris
2.8?
Certainly. It shouldn't (famous last words) make any
difference for the Standard library functions, though,
because the Solaris 8 libraries have the exact same APIs
as their predecessors -- we don't want everyone to recompile
all their code simply to upgrade the O/S, after all!
Nonetheless, it seems an ill-advised way to go about
things. Also, you mentioned that you're using gcc, and I
seem to recall reading somewhere that gcc likes to modify
the system-provided include files to suit its own purposes;
I don't know whether this is true for the particular gcc
version you're using (and maybe what I read was just an
ill-informed rumor) -- anyhow, there's plenty of room for
glitches.
Still, it seems more probable that something else in
your complicated configuration is doing something you don't
expect, and making the C code behave in ways that aren't
apparent from its appearance. Go back to your -E output
and examine what the crucial fprintf() looks like after
it's been through the preprocessor's wringer.
Since you seem to have some kind of configuration or
release engineering problem rather than a C language issue,
I think comp.lang.c is no longer the appropriate forum for
the matter. The C you've shown is just fine (assuming
reasonable #include files, definitions for data types and
so on), so you're faced with debugging your compilation
environment. I'm afraid comp.lang.c can't be much help
with that.
Oh, and since I've been talking about Solaris it's
probably a good idea to make explicit a disclaimer that
is usually understood tacitly on Usenet: I work for Sun,
but I do not speak for Sun. If you need an "official
position" on something, better get somebody else.
Good luck!