Re: How to use C89 with certain C99 features

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 5, 2011 at 5:44 PM,  <richardcavell@xxxxxxxx> wrote:
>> We have such situations where the platforms w/o vaargs are
>> "small" anyway and the overhead for __FILE__ in the binaries is
>> bad anyway, so simple solution is to simply on those platforms do
>> /not/ use file and line; two implementations of myfunc: one with
>
> Well, because it's a Wikipedia bot, it's entirely foreseeable that the
> program will encounter an error through no fault of its own (Internet
> connection goes down, Wikipedia servers lag, unusual activity on Wikipedia
> results in rare unhandled error, etc).  Error conditions have to be
> reported, and __FILE__ is a part of that.

So it seems suited to run it on a system supporting a compiler
with vaargs.

Yes, failure conditions have to be reported, but I disagree
that __FILE__ is part of a failure message, because the user
should not be expected to read the sources to understand a
message (also, a source code identifier, such as a unique version
number, is additionally needed in this case).
Why not include __FUNCTION__, __func__ or __PRETTY_FUNCTION__, if
avialable? I think usually very helpful (if avialable) but also
not portable (to C89), AFAIK.

BTW, interesting to read this argument in C language context
(usually it comes from Java people [and some
InternalUnknownErrorException, thrown in File.open() in
File.java:12345] and I have the impression that often it is used
only as excuse for not writing meaningful, well-thought-out and
carefully written messages. SCNR.).

>> {
>>   struct timeval t = { 0 };
>>   t.tv_sec = seconds;
>> }
>
> Okay, but what about if I have const members?

You cannot have const members with runtime data.
As I understand it, the "small old" compilers may locate
const data into ROM (or other RO memory), which makes it
impossible to initialize it with runtime data, so again the
problem may not be the compiler language / version, but
properties of the equipment. If you want your code to be runable
on such systems, you cannot use it.

Is this right? I hope someone on the list corrects me?

But, as told here by someone else before, it should be checked
whether the price of less good code is worth the potential
possibility to run it on exotic platforms. Maybe it is simply not
needed to be able to run a Wikipedia Web Bot on a microwave oven?
:)

oki,

Steffen



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux