The MASM Forum

General => The Workshop => Topic started by: jj2007 on August 19, 2015, 05:20:39 AM

Title: Linking a Masm32 routine to G++
Post by: jj2007 on August 19, 2015, 05:20:39 AM
Anybody managed to use a Masm32 algo in G++? It throws e.g.

error: expected constructor, destructor, or type conversion before ';' token

for

extern "C" __stdcall atodw(char *szStr);

int main(void)
{
    int somenumber=atodw("123");
Title: Re: Linking a Masm32 routine to G++
Post by: Vortex on August 19, 2015, 06:48:05 AM
Hello Jochen,

You need to specify the return type of the function in the declaration :

extern "C" void __stdcall StdOut(char *szStr);

int main(void)
{
    char s[]="Hello world!";
    StdOut(s);
    return 0;
}



set PATH=%PATH%;\MinGW\bin

g++ -c hello.cpp

g++ -static-libstdc++ -static-libgcc -s hello.o -o hello.exe \masm32\lib\masm32.lib
Title: Re: Linking a Masm32 routine to G++
Post by: jj2007 on August 19, 2015, 08:35:00 AM
Thanks, Erol. The hello world is working now.
Title: Re: Linking a Masm32 routine to G++
Post by: jcfuller on August 19, 2015, 11:06:02 PM
Jochen/Erol,
  Isn't that a violation of Hutch's masm32 library use policy?

James
Title: Re: Linking a Masm32 routine to G++
Post by: hutch-- on August 20, 2015, 12:07:58 AM
Nope.
Title: Re: Linking a Masm32 routine to G++
Post by: jcfuller on August 20, 2015, 12:52:07 AM
Ok,
now I remember why I could not use it; but to be fair it was several years ago and my memory fades more every day.
Item #4:
You cannot use the MASM32 Project to write software for Non-Microsoft Operating Systems
when I was tinkering with jwasm on Linux
:)

Hutch,
  That was also a Microsoft restriction was it not?
Now that they are providing  cross platform compiling with Visual Studio 2015 will that be relaxed?

James
Title: Re: Linking a Masm32 routine to G++
Post by: Vortex on August 20, 2015, 04:03:49 AM
Hello Jochen,

The C equivalent :

extern void __stdcall StdOut(char *szStr);

int main(void)
{
    char s[]="Hello world!";
    StdOut(s);
    return 0;
}


set PATH=%PATH%;\MinGW\bin

gcc -c hello.c

gcc -static-libstdc++ -static-libgcc -s hello.o -o hello.exe \masm32\lib\masm32.lib

Title: Re: Linking a Masm32 routine to G++
Post by: hutch-- on August 20, 2015, 03:25:39 PM
> Now that they are providing  cross platform compiling with Visual Studio 2015 will that be relaxed?

Nope.

I am inclined to return back to GPL what I get from it, nothing.