Re: good c compiler



jacob navia wrote, On 25/09/08 21:10:
Flash Gordon wrote:
Keith Thompson wrote, On 25/09/08 16:34:
Flash Gordon <smap@xxxxxxxxxxxxxxxxx> writes:
[...]
Jacob has, IMHO, made the correct decision in following the platform
ABI for the platforms he is targeting. He just needs to stamp in big
letters across his documentation that on Windows he does not follow it
for "long double" (for perfectly valid reasons) and so people need to
stick to float/double in interfaces which might be accessed from other
implementations.
[...]

Are you sure about that?

My understanding from this thread is that lcc implements long double
with the same size as double, and lcc-win implements long double with
a larger size than double. I haven't seen anything in this thread to
indicate that the latter violates the Windows ABI. But then, I'm not
familiar with the Windows ABI.

If you get a library compiled with lcc-win32 that uses it's long double how will you pass it a correct value when calling the library from MSVCC? Same for return values. As to passing pointers to long doubles...

Same problem in reverse if the library is compiled with MSVC and the header refers to long double, although way round you can fix it by changing the header.

I've no idea if the ABI defines the format for long double, but using a different format not supported by a major vendor can lead to problems.

Note that I'm NOT saying Jabob's decision is bad or unreasonable, just something the users of his compiler need to be aware of IF their code will be linked with code compiled with other compilers.

No Microsoft header uses long double.

I said a library built *with* MSVC. Do you know every single library built using MSVC?

The ABI will not mention long
double, so there isn't any problem.

Please actually read what I wrote. There IS potential for problems.

If a long double arguments get's
passed to an MSVC library function the prototype is double and NOT long
double since MS never uses long double in their headers.

I was not talking about libraries written BY MS, I was talking about libraries build USING MSVC. Have you looked at the headers for every single library that is distributed as a binary and built with MSVC?

So, there is no
problem, the long double will be passed as a double.

Not if the header you have never seen specifies long double.

Also you have completely failed to address the converse situation where someone builds a library using lcc-win32 using long double in the interface and I then try (without access to the source of the library since this could be one of your commercial customers) to link to it from code compiled with MSVC.

As I say, your decision to use higher precision and range for long double is perfectly defensible but the restrictions it imposed on linking with code built with different compilers should be clearly stated.
--
Flash Gordon
If spamming me sent it to smap@xxxxxxxxxxxxxxxxx
If emailing me use my reply-to address
See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/
.



Relevant Pages

  • Re: good c compiler
    ... I was not talking about libraries written BY MS, I was talking about libraries build USING MSVC. ... I'll take your word on gcc. ... double is perfectly defensible but the restrictions it imposed on linking with code built with different compilers should be clearly stated. ...
    (comp.lang.c)
  • Re: good c compiler
    ... software that compiles under MSVC. ... There are valid reasons for doing this and these apply to closed source libraries as well as open source code. ... For all I know unlike with some other compilers you provide no compatibility with libraries built with MSVC, I just assumed your users might want to be able to use third-party pre-built libraries, since I know that I do, and in that case they need to be aware of any compatibility issues. ...
    (comp.lang.c)
  • Re: Why C is really a bad programming language
    ... by compilers with different ideas of the size of time_t? ... You can get pretty close with any ABI that specifies passing arguments ... I don't think a struct argument would be a problem; ... new apps will be linked with the new libraries. ...
    (comp.lang.c)
  • ABI related question
    ... if there exists a standardized ABI does ... that mean that libraries compiled for a particular platform by ... different compilers (such as say for Linux x86) are inter-operable i.e ...
    (comp.lang.cpp)
  • Re: Dynamically loading a static C library (compiler suggestion?)
    ... I am programming a microcontroller, ... Manufacturer suggests using one of the following compilers: ... the tools I use produce OMF so I ... for dynamically loading libraries. ...
    (comp.os.msdos.programmer)