flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > Fasm with C |
Author |
|
LocoDelAssembly 12 May 2010, 14:31
If you use "public MyVar as '_MyVar' " instead it will compile and AFAIK it will link with your C object despite the type-less nature of the symbol.
|
|||
12 May 2010, 14:31 |
|
masterducky 12 May 2010, 15:30
Thanks for the answer LocoDelAssembly!
No it wont compile that way either. But i found out what i missed in the example code and now it compiles like this: Code: public MyVar as '_MyVar' MyVar dd 0 But i cant seem to access it in C. I get "error LNK2019: unresolved external symbol "int MyVar"" error. Is there any relation of the size that i declared it as DD in fasm and INT in C? Can it be the problem? |
|||
12 May 2010, 15:30 |
|
LocoDelAssembly 12 May 2010, 16:11
Have you tried without the underscore and adding one more?
|
|||
12 May 2010, 16:11 |
|
masterducky 12 May 2010, 16:50
No, but i found it:
Code: extern "C" int MyVar; This is it. Now i have access. One more question though: Do i still need to invoke ExitProcess in the fasm code when i link it with C ? |
|||
12 May 2010, 16:50 |
|
pelaillo 12 May 2010, 19:22
Quote:
If you have the "C" main() procedure as the entry point, your compiler will include all the exit routines to properly terminate the program. Check it in a dump of the linked executable. |
|||
12 May 2010, 19:22 |
|
bitshifter 13 May 2010, 00:13
It sounds like you are really using C++ (not C)
So for it to work under either language you could do this... Code: #ifdef __cplusplus extern "C" { #endif /* TODO: put stuff here... */ #ifdef __cplusplus } #endif _________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. |
|||
13 May 2010, 00:13 |
|
masterducky 13 May 2010, 07:06
Thanks a lot Pelaillo and Bitshifter!
|
|||
13 May 2010, 07:06 |
|
Tyler 05 Jun 2010, 22:12
You might be interested in http://en.wikipedia.org/wiki/Name_mangling#How_different_compilers_mangle_the_same_functions, it explains the reason you need to use "extern 'C'" on that page also. Name mangling is really unstandardized for C++.
|
|||
05 Jun 2010, 22:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.