NO

Recent Posts

Pages: 1 [2] 3 4 ... 10
11
Chit-Chat / Re: Bored?
« Last post by jj2007 on September 23, 2017, 12:19:50 AM »
Yeah, that looks ... different:
Code: [Select]
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

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:....

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)
12
Chit-Chat / Re: Bored?
« Last post by TimoVJL on September 22, 2017, 04:54:59 PM »
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
13
Chit-Chat / Re: Bored?
« Last post by jj2007 on September 22, 2017, 02:06:37 PM »
messy, these options are important in that case:
cl /GS- /MD /ENTRY:main /FIXED

Sure, let's make a test:
Code: [Select]
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe" /GS- /MD /ENTRY:main /FIXED "Tmp.c" user32.lib kernel32.lib ucrt.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 '/ENTRY:main'
Tmp.c
Tmp.c: fatal error C1083: Cannot open include file: 'XED': No such file or directory

So sad, as Donald Dumb would say :'(

But let's test also the long commandline of aw27:
Code: [Select]
J:\Masm32\MasmBasic\Res>"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe" /GS- /TC /GL /analyze- /W3 /Gy /Zc:wchar_t /
Zi /Gm- /O1 /fp:precise /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /
Oi /MD /nologo /Fe /Fombr.obj Tmp.cpp /link /OUT:mbr.exe /ENTRY:main /SUBSYSTEM:CONSOLE /DYNAMICBASE:NO /FIXED /MACHINE:X86 /OPT:REF /SA
FESEH:NO /INCREMENTAL:NO kernel32.lib ucrt.lib
Tmp.cpp
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(79): error C2059: syntax error: '['
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(110): error C2059: syntax error: '['
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(141): error C2059: syntax error: '['
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(153): error C2059: syntax error: '['
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(163): error C2059: syntax error: '['
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(174): error C2059: syntax error: '['
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(184): error C2059: syntax error: '['
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(194): error C2059: syntax error: '['
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(206): error C2059: syntax error: '['

More trial and error...? Now I will tell you a secret: This ridiculously simple hello world proggie fails miserably with various versions of MCVC and GCC, despite the commandlines suggested by real expertsTM, but it builds fine with Pelles C - provided you do something very logical, that is, add a W to the line
HANDLE hFile = CreateFile(L"\\\\.\\PhysicalDrive0", ...

Of course, it will still fail miserably with the other compilers, but hey, wouldn't it be fun to spend some weeks on solving the puzzle? Especially if you are bored, of course 8)
14
Chit-Chat / Re: Bored?
« Last post by TimoVJL on September 22, 2017, 09:20:07 AM »
messy, these options are important in that case:
cl /GS- /MD /ENTRY:main /FIXED

This Small Application Wizard could be useful.
15
Chit-Chat / Re: Bored?
« Last post by jj2007 on September 21, 2017, 08:24:03 PM »
Quote
Countless C/C++ coders searching the internet in a desperate attempt to understand their endless error messages. Trial and error as the ultimate programming paradigm

That is just a simple description of the situation. And btw, if I do something in C, normally I use Pelles C because it just works, instead of dumping incomprehensible error crap on the user. Practically all the projects you posted here just build "as is", without desperate google searches.

@JJ,
cl /GS- /TC /GL /analyze- /W3 /Gy /Zc:wchar_t /Zi /Gm- /O1 /fp:precise /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MD /nologo /Fe /Fombr.obj mbr.cpp /link /OUT:mbr.exe /ENTRY:main /SUBSYSTEM:CONSOLE /DYNAMICBASE:NO /FIXED /MACHINE:X86 /OPT:REF /SAFESEH:NO /INCREMENTAL:NO kernel32.lib ucrt.lib

Builds a 3 KB exe.

I am sure you will not get it to work, as usual. :badgrin:

Isn't that "commandline" funny?
16
Chit-Chat / Re: Bored?
« Last post by Vortex on September 21, 2017, 07:50:46 PM »
Hi Timo,

I think the main problem is that M$ is deliberately obfuscating their stuff, especially the header files. Very complicated files which are not easy to translate to other languages. The increasing level of obfuscation and complexity might be the reason of that animosity. On the other side, Pelles development suit is a nice package not complicated like M$'s Visual Studio. As you mentioned, C\C++ examples can be built with the minimal dependencies like msvcrt.dll  Sadly, not everyone is aware of this.
17
Chit-Chat / Bored?
« Last post by TimoVJL on September 20, 2017, 03:25:01 PM »
If someone have a cloudy day, check this forum chain:

http://masm32.com/board/index.php?topic=6546.msg70177#msg70177

You learn how asm programmers hate C ;)

I don't hate asm and i can compile that example C/C++ code with Visual Studio 2008 with Microsoft C/C++ compiler version 19.10 and with WinDDK 7600, and result exe is 7 kb using msvcrt.dll.

So C/C++ compiler isn't the problem, only the linked CRT.

18
Work in progress / Re: C declaration explainer
« Last post by frankie on September 18, 2017, 12:00:53 PM »
Hello Jack,
yes is the first use of a bigger project.
It will (may)be a C compiler in future.
For now generates explanation in english, and help me in the development if everybody reports the problematic declarations (so I can debug the code).
It understands also many constructs, (not the preprocessor, the switch statement, the goto, the enums and something else).
You can try something like:
Code: [Select]
int array_of_ints[10][10];
_Static_assert(sizeof (array_of_ints)  == sizeof(int)*10*10, "'array_of_ints' doesn't " "occupy" " 400 bytes!");
_Static_assert(sizeof(char)  == 1, "'char' is " "not" " equal to 1!");
_Static_assert(sizeof(short) == 2,
"'short'"
" is not"
" equal to 2!");
_Static_assert(sizeof(double) == 8, "'double' is not equal to 8!");
_Static_assert((1<<2)+1 == 2*2+1, "5" " != "
"5"
" ...");
Shows sizeof, arrays and string concatenation. Or:
Code: [Select]
typedef int INTEGER;
INTEGER int1 = 100;
float FloatVal = 0.34e-1;
float FloatHex = 0x1.99999ap-4;
typedef char * CHAR_PTR;
CHAR_PTR pChar;
int fnproto(int a, char *c, float f);
const unsigned int * restrict const * restrict const flt;
That shows constants input and qualified declarations. Or a function definition:
Code: [Select]
int fn(int a, int b)
{
typedef int MyInt;
    MyInt c = (MyInt){2};
    int d = c + 1, z = d-1+array_of_ints[1][1];
_Static_assert((1<<2)+1 == 2*2+1, "5 != 5 ...");

    if (flt == 0)
    {
        c = (MyInt)(void *)(c + d--) >> 2;
    }
    else
    {
        flt = 0;
    }

    do
    {
        c = c+1;
    }
    while (c<100);

    while (++c > c-a)
    {
        c = c - 1;
c += 2;
d |= c;
    }

    int res = (c + a) * b - 2  != 0 ? a >> (int)((3 & 1)) : (int)((b - a) % 4);
    return (c + a) * b - 2  != 0 ? a + (3 & 1) : (b - a) % 4;
    c = 3;
}
This will trigger a warning for unreachable code.
19
Work in progress / Re: C declaration explainer
« Last post by jack on September 18, 2017, 11:49:15 AM »
hello frankie
so this is a C declarations to english? could be helpful to a beginner like me.
20
Work in progress / C declaration explainer
« Last post by frankie on September 17, 2017, 11:57:45 PM »
Playing around with compiler techniques I produced something that, at this stage, can be used to explain in more or less plain english the C declarations. Even those very complicate.
I.e. from a declaration as:
Code: [Select]
void (*bsd_signal(int sig, void (*func)(int)))(int);
You will get:
Code: [Select]
// 'bsd_signal' is: function having 2 parameters (int, pointer to function having 1 parameter (int) returning void) returning pointer to function having 1 parameter (int) returning void.
void (*bsd_signal(int sig, void (*func)(int )))(int );

You can use the executable with command line:
Code: [Select]
fcc -T:Ast-C test_decl.c
The file test_decl.c is a sample source included in the zip.
The executable is a based on my compiler, so the I/O use files only.
After compilation, you'll find in the directory a freshly created file named test_decl.AstOut.c (the name of input file  followed by .AstOut postfix). You can also use the -Fo switch to change output file name. I.e.:
Code: [Select]
fcc -T:Ast-C -Fo:test_out.c test_decl.c
Will create an output file named test_out.c.

Added an advanced demo with a test file that does something more that explain declarations ;)
Pages: 1 [2] 3 4 ... 10