[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Bug report: Compile with Microsoft and Intel compiler
From: |
Jerker Bäck |
Subject: |
RE: Bug report: Compile with Microsoft and Intel compiler |
Date: |
Fri, 29 Apr 2005 16:35:33 +0200 |
Eli Z:
> ??? Sorry, I'm mightily confused. What do you mean by ``defined in
> the runtime library''? A library does not, AFAIK, include any
> declarations of function's prototypes. It includes _their_code_.
I mean the runtime library headers, not the import libs.
> Next, what do you mean by ``local defines'', and what is that "fatal
> error 2373"? E.g., can you compile, link, and run the following toy
> program (which is a simplified replacement for the CHDIR command)?
> If this compiles at the highest possible warning level and runs and
> expected, why can't we throw together a unistd.h and use it? What am
> I missing?
> -------------------------------------------
> _CRTIMP int __cdecl _chdir(const char *);
>
> int main(int argc, char *argv[])
> {
> if (argc > 1)
> _chdir(argv[1]);
> return 0;
> }
> -------------------------------------------
Visual Studio, link to msvcrt.lib, compile with /W4 This is actually tricky
Made some test with different variants of this
1) No, _CRTIMP undefinied
2) Add #include <stdlib.h> at the top
No, error LNK2019: unresolved external symbol "int __cdecl _chdir(char
const *)"
3) Change prototype to "int _chdir(const char *);
No, error LNK2019: unresolved external symbol _chdir
4) Change prototype to "int __cdecl _chdir(const char *);
No, error LNK2019: unresolved external symbol _chdir
5) Exchange prototype with #include <direct.h>
Yes, no problem - works also with /Gz (__stdcall)
<direct.h> extracts
#ifdef _MSC_VER
#pragma pack(push,8) // 8 byte alignment - compiler default
#endif /* _MSC_VER */
_CRTIMP int __cdecl _chdir(const char *);
Comment:
No 2 should logically work, but don't. Strange enough I got no 3 to work
once, but couldn't reproduce it later. Conclusion: The only safe way is to
include the right headers and disable any local attempt to define the CRT
functions again.
> I need to see how it defines chdir, dup2, environ, getpid, and mktemp,
> without the leading underscores.
> Also, what is the precise definition of _CRTIMP?
> > there is also prototypes for oldnames.lib functions (no underscore
> > function aliases)
The meaning of _CRTIMP is to direct the compiler to either
__declspec(dllimport) or __declspec(dllexport) or nothing.
<direct.h> states:
#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
#endif /* _CRTIMP */
We are a program so _DLL is not defined => _CRTIMP means nothing.
However, apparently this is not as simple as it looks.
> > So, if you plan what I think you're planning - don't, it's
> not a good idea.> ??? Please explain why. Especially since MinGW,
> evidently, uses similar techniques to create its version of unistd.h,
> as Earnie told us just now.
As you see, I have no good answer of this. I just think it will very
difficult to get locally defined prototypes of the CRT functions to be
accepted by the compiler. And what about the calling convention issues?
I think you all make this more difficult then it really is:
A simple fact:
* The Microsoft/Intel compiler don't like these prototypes.
Solution: Disable them if using MSC. Include <direct.h>
Regards JB
- Re: Bug report: Compile with Microsoft and Intel compiler, (continued)
- RE: Bug report: Compile with Microsoft and Intel compiler, Jerker Bäck, 2005/04/27
- Re: Bug report: Compile with Microsoft and Intel compiler, Eli Zaretskii, 2005/04/28
- RE: Bug report: Compile with Microsoft and Intel compiler, Jerker Bäck, 2005/04/28
- Re: Bug report: Compile with Microsoft and Intel compiler, Eli Zaretskii, 2005/04/28
- RE: Bug report: Compile with Microsoft and Intel compiler, Jerker Bäck, 2005/04/28
- RE: Bug report: Compile with Microsoft and Intel compiler, Jerker Bäck, 2005/04/28
- Re: Bug report: Compile with Microsoft and Intel compiler, Eli Zaretskii, 2005/04/29
- RE: Bug report: Compile with Microsoft and Intel compiler,
Jerker Bäck <=
- RE: Bug report: Compile with Microsoft and Intel compiler, Jerker Bäck, 2005/04/29
- RE: Bug report: Compile with Microsoft and Intel compiler, Paul D. Smith, 2005/04/29
- Re: Bug report: Compile with Microsoft and Intel compiler, Eli Zaretskii, 2005/04/29
- Re: Bug report: Compile with Microsoft and Intel compiler, Eli Zaretskii, 2005/04/29
- Re: Bug report: Compile with Microsoft and Intel compiler, Paul D. Smith, 2005/04/29
- Re: Bug report: Compile with Microsoft and Intel compiler, Eli Zaretskii, 2005/04/29
- Re: Bug report: Compile with Microsoft and Intel compiler, Eli Zaretskii, 2005/04/29
- Re: Bug report: Compile with Microsoft and Intel compiler, Alessandro Vesely, 2005/04/28
- Re: Bug report: Compile with Microsoft and Intel compiler, Eli Zaretskii, 2005/04/28
- Re: Bug report: Compile with Microsoft and Intel compiler, Paul D. Smith, 2005/04/28