Re: Porting C software



On 24 Aug, 11:50, "cr88192" <cr88...@xxxxxxxxxxx> wrote:
"Richard Heathfield" <r...@xxxxxxxxxxxxxxx> wrote in message
news:lcednRcb4oXiBFPbnZ2dnUVZ8v-dnZ2d@xxxxxxxxx
Jean-Pierre Mestre said:

Well, I'm not sure. As others say it may need to be ported again
therefore perhaps it's better to remove some features only recognized
by lcc.

Is there a description anywhere of a "common subset" of C recognized
by all compilers?

[C90]

<snip>

C90 is good, yes...

C99 contains a few features that look particularly problematic (dynamic
arrays and so on...).

and the rest


still, should work pretty good as a reference for writing portable code (to
what extent what one writes can be made portable...).

most of what I write is portable. And the non-portable bits can be put
in a separate module.


the standard explains more than a few things, but stops well short of a
complete explanation

that's what it's supposed to do...


(for example, of the exact calling conventions,

calling conventions!!! When do you need to know those? I've worked
on large systems (ok, lets just say fairly not-small). I've worked on
embedded systems. And I didn't need to know the calling conventions.
The last time I did was when there was no source code debugger so we
debugged the assembler. Great fun.


data representations,

how often do you need those? I like to have an "octet" (unsigned
8 bits) for external representation. But otherwise who cares?


... employed by an architecture, which may be particularly
relevant for more involved projects).

what are these "more involved projects"?


another approach (though better when combined with the standards, so one
knows more what is and is not standard) is to take some specific
implementation (say, gcc), and using this as a general reference
implementation ('how things work' and similar questions).

no no no!!!! Don't Do This!!! GCC is a particular implementation.
It can only tell you about GCC. Why not use the standard? You can
go a long way without getting implementation specific. I'm not
even sure what my current software is going to be targetted on
in the end. And mostly it doesn't matter.


this is generally
what I have done. how and what is done in gcc is something I personally find
particularly relevant to my own efforts.

my case, I have a compiler, it supports a subset of C (and also has a few
extensions). well, I don't have working static declarations and inline
functions as of yet, but I do have builtin geometric vectors and
quaternions, and other misc extension features...

games?


note: the purpose of my compiler is not to compete with gcc, but to fill a
nice currently left void by gcc, that of being an at-runtime compiler (IMO,
a lot more powerful and useful than a typical script VM).

an interpreter or maybe a JIT compiler. Sounds cool.


now, if in my compiler, I go and write code making use of a bunch of vector
and quaternion math using my extensions, well, then, it is not portable. I
still decided having them was worthwhile though.

it's your language. If it solves problems for you then it's good.
Though you might have looked at things like Python, Perl, Tcl etc.
which might have already solved your problem.


also, apparently, unlike gcc I went and implemented imaginary types, having
failed to notice that gcc did not until generally afterwards. oh well...

or such...

<shrug> you have quaternions so you aren't trying to be standard C;
why worry about imaginary types. Hmmm imaginary types. You only think
you've stored your data but behind your back it mysteriously vanishes.
Didn't <large software company> implement that years ago?


--
Nick Keighley

We recommend, rather, that users take advantage of the extensions of
GNU C and disregard the limitations of other compilers. Aside from
certain supercomputers and obsolete small machines, there is less
and less reason ever to use any other C compiler other than for
bootstrapping GNU CC.
(Using and Porting GNU CC)

[IRONY IMPAIRED NOTE: I put that in because I thought it was funny]

.



Relevant Pages

  • Re: non-standard functions in libc -- bad design?
    ... standard supported by a compiler/library, ... I'd call them extensions. ... gcc doesn't get a vote. ... gcc is just a compiler, ...
    (comp.lang.c)
  • Re: Whats the story with the "end of XP"?
    ... Support gives them access to the larger body ... The same compiler suite may be "best" in both ... In the case of ByteCraft compilers, you are truly expert in your field, you work closely and rapidly with customers if there are any issues, and you have top class testing and quality control. ... understanding the inner workings of a relatively simple compiler like GCC ...
    (comp.arch.embedded)
  • [RFC][PATCH-2.6] Clean up and merge compiler-*.h
    ... the kernel headers in include/linux to include/linux-abi. ... * Common definitions for all gcc versions go here. ... -/* Some compiler specific definitions are overwritten here ...
    (Linux-Kernel)
  • Re: LPC900/80C51 Compiler Toolchain
    ... >> supported by GCC, and so they invest. ... > if they already have their in-house compiler. ... one of the main companies in the Symbian consortium ... vendor to provide a good compiler for Atmel AVRs and eventually became ...
    (comp.arch.embedded)
  • Re: J3s workings
    ... by having compiler writers, both commercial and volunteer, (gfortran ... If those features are adopted by several compilers, ... I avoid using vendor extensions even when they are ... And features supported by only a single vendor are even more rare ...
    (comp.lang.fortran)