General > Chit-Chat

Bored?

<< < (2/3) > >>

TimoVJL:
Oops.
cl /GS- /MD test.c /LINK /ENTRY:main /FIXED /NOCOFFGRPINFO kernel32.lib

EDIT:
cl /GS- /MD test.c -link /ENTRY:main /FIXED /NOCOFFGRPINFO kernel32.lib

jj2007:
Yeah, that looks ... different:
--- Code: ---J:\Masm32\MasmBasic\Res>"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe" /GS- /MD test.c /LINK /ENTRY:main /FIXED /NO
COFFGRPINFO kernel32.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9002 : ignoring unknown option '/LINK'
cl : Command line warning D9002 : ignoring unknown option '/ENTRY:main'
cl : Command line warning D9002 : ignoring unknown option '/NOCOFFGRPINFO'
test.c
test.c: fatal error C1083: Cannot open include file: 'XED': No such file or directory
--- End code ---

Of course, with a lot of experience and a bit of trial and errorTM, you can overcome error D9002 (hint: four chars need to be changed in the commandline). Once you have solved this issue, you will stumble into a new, amazing puzzle called "error C2059", and here I am bit unfair and offer you the solution right away:
--- Quote ---I tracked down the reason of those sudden compiler errors.

In the great tradition of windows.h it appears that Microsoft introduced tokens that cause name clashes with our codebase.

In our precise case, we had: #define Null (void*)0

Somewhere in our code, we need to use the offsetof macro and to make it available we #include <stddef.h>

I tracked down stddef.h in turns includes crtdefs.h which ends up including sal.h where our Null macro seems to clash with source code annotation in MS headers...

As a workaround, we did:....
--- End quote ---

There is no Null macro in aw27's code, but ... just try yourself, it's fun. There are people who play Zelda or Super Mario, but IMHO compiling a hello world proggie with a Micros**t compiler can be even more fascinating and challenging 8)

TimoVJL:
Sure i made a lot of mistakes.

test.c

--- Code: ---void __cdecl mainCRTStartup(void)
{
__declspec(dllimport)void __cdecl exit(int status);
int __cdecl main(void);
exit(main());
}
int __cdecl main(void)
{
return 0;
}
--- End code ---
cl /GS- /MD test.c /link /FIXED /NOCOFFGRPINFO
creates 1.5 kb exe

test.cpp needs some changes
--- Code: ---#ifdef __cplusplus
extern "C" {
#endif
void __cdecl mainCRTStartup(void)
{
__declspec(dllimport)void __cdecl exit(int status);
int __cdecl main(void);
exit(main());
}
#ifdef __cplusplus
}
#endif
int __cdecl main(void)
{
return 0;
}
--- End code ---
so this is the C/C++ compiler part of this story.
headers and CRT's are the next part.

Windows Driver Kit Version 7.1.0 have headers and libs for WindowsXP/Windows 7.
I collected header set from there.
An another is Microsoft Windows SDK for Windows 7, but it don't have msvcrt.lib for msvcrt.dll.

jj2007:

--- Quote from: TimoVJL on September 23, 2017, 10:26:26 AM ---Sure i made a lot of mistakes.
...
so this is the C/C++ compiler part of this story.
headers and CRT's are the next part.

--- End quote ---

No, Timo, you didn't do any mistakes. And I don't hate C, but I despise those who claim that there is a C "standard", that it is "portable" and other hot air promises. When you present a Micros**t C compiler with a hello world proggie that was designed for a version that is two years older or younger than the current one, it complains bitterly that it doesn't know how to build it. Throw it at GCC, and it will complain with loads of incomprehensible error messages. The whole "compatible and portable" story is just fake, it is a ridiculous religious belief. Assembler may be restricted to Windows XP and higher, but a) that covers 95% of the desktop market, and b) all my code builds out of the box with ML 6.15, 8.0, 9.0, 10.0, ... and JWasm, AsmC, UAsm64 and UAsm32. That is a standard.

Vortex:
Jochen is right. Masm and the compatible Macro Assemblers are processing the same source code without those adventures. The problem is that compilers like MS VC and MinGW are very complicated. Plus, the obfuscated and complicated header files like hieroglyphs is another serious problem.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version