Re: Translating an embedded C algorithm -- OT



Cesar Rabak wrote:

if (a = 1) {

if (a == 1) {

No need for separate tools, gcc -Wall issues an informative warning.
And you do compile with -Wall, right?

Not all C code is compiled [only] with gcc...

If you use another compiler and it does not provide the functionality that you have for free from gcc, you should certainly report this complaint to the vendor.

More to this, if you are at least moderately serious about robustness of your code, I'd expect that you compile it (or at least its isolated critical parts) with a *set* of compilers (the fact that gcc is free makes it an easy candidate) to get as much feedback as you can. Preferably on a regular basis, nightly build or such.

If your working environment is so constrained that you don't even run noghtly builds on a set of compilers, you can always write a simple Perl/Tcl/Python/awk/grep/whatever script that will highlight such constructs - just look for if and = that comes in the subsequent pair of parentheses.

Note also that in C++ the above constructs are both legal provided that the following two are true:

1. assignment operator returns something ...
2. ... that is implicitly convertible to some fundamental type.

These two points already give you many opportunities to guard against such mistakes.

In general - I totally understand your points, but I don't count them as showstoppers.

And coming back to Ada - can you believe that when I write Finalise instead of Finalize, it is legal but does not do what I want? Unbelievable. Any compiler options for this? ;-)

(I know - in some future I will be able to enjoy the override keyword.)

--
Maciej Sobczak : http://www.msobczak.com/
Programming : http://www.msobczak.com/prog/
.



Relevant Pages

  • Re: How do I install this missing library?
    ... you really should be carefully following LSTC's installation ... libg2c is part of gcc. ... to tell a newcomer to compile. ... like the source code to GNU tar, and make sure you understand what's ...
    (comp.os.linux.misc)
  • Re: HPGCC Questions ladies and gentlemen!!!
    ... No matter how you slice it in order to compile a C program you need to know ... it took a few hours just to get gcc running in my computer ... of the students that used an ide in the c++ class I took a few years ago. ... so why not use a data inspector if it's available? ...
    (comp.sys.hp48)
  • Re: Just starting out in C
    ... was based on the ANSI standard as it was being developed. ... Some words about gcc: ... gcc provides some extensions to the language that aren't supported by ... For example, to compile the Hello, World program, use the command line ...
    (comp.lang.c)
  • Re: Aquarius prolog so fast?
    ... Mercury cannot do all this because Mercury cannot keep track of the fact ... you need this capability quite rarely, ... Why not the alternative GCC back-end, ... While Mercury can compile to the internal data structures of the gcc backend, ...
    (comp.lang.prolog)
  • Re: Question about gcc on OS X 10.0.4.11 Tiger
    ... running Linux and gcc 4.0.2. ... How do I switch to a different version of gcc to compile with on OS X ... fgetsis a libc function and is not really part of the compiler. ... int main(int argc, char* argv){ ...
    (comp.sys.mac.programmer.help)