News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Arnaud

Compiling CPCtelera project under Visual C++ 2015

Started by Arnaud, 12:05, 04 September 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Arnaud

Hello,
in order to debug the C part of my game i have coded my own cpctelera library for windows.

This library of course do nothing  ;) because it's essentialy stub functions, but i can run in debug mode and use the static code analysis of visual.

In order to ignore the assembler par of my code i have used the following code :

#ifndef _MSC_VER

__asm
...
__endasm;

#endif


What i wanted to do :

#define __asm #ifndef _MSC_VER
#__endasm #endif


In this way all asm part of the code would have been automaticaly ignored.
But of course it can't work  :D

Is there another way to do this ?

Thanks.

SRS

Not sure there is a solution with that "in makro".

But you could to an all source file "find&replace" before visual c

with "__asm" replaced by "/* __asm not for visual c"

and "__endasm;" replaced by " __endasm; not for visual c */" ...

So you can easily replace back for compiling with sdcc maybe ?

Arnaud

Yes in this way it works  :)

But my goal was to compile my code without have to modify it.

Actually it's not the case because i have to add :

#ifndef _MSC_VER

__asm
...
__endasm;

#endif


I'm looking for a way to compile my project ignoring the asm part and without modify it  :D




Docent

Quote from: Arnaud on 14:01, 04 September 16
Yes in this way it works  :)

But my goal was to compile my code without have to modify it.

Actually it's not the case because i have to add :

#ifndef _MSC_VER

__asm
...
__endasm;

#endif


I'm looking for a way to compile my project ignoring the asm part and without modify it  :D

I afraid that only putting your asm code between #ifndef _MSC_VER / #endif will do the trick.

Alternatively, if your assembler ignores c comments like /* */
you can try this:

#ifndef _MSC_VER

#define __asm if (0){
#define __endasm }

#endif


This will cause the code to be excluded, but the problem is that vc will try to do syntax analysis on the part between __asm/__endasm anyway, so you'll need to put your asm code between c comments.
But it still requires some modification to the source code.


SRS


Docent

Quote from: SRS on 16:21, 04 September 16
The main problem is :

(x86) C also knows __asm and __endasm - they are kind of "hardwired" .

__asm

http://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=9&ved=0ahUKEwiN5-eAgvbOAhVJWxQKHfNLB6AQFghhMAg&url=http%3A%2F%2Fwww.krucker.ch%2Fskripten-uebungen%2FInfUeb%2FAssembler%2520in%2520C-CPP%2520Programmen%2520MSVC.pdf&usg=AFQjCNGKaLg8dn5_WrNTron8IMcBD_AjEQ&cad=rja

I tried this with dev-cpp, too ...

It is not a problem, because keywords can also be redefined by a macro and replaced by the preprocessor with a different text before tokenization. This is possible due to the way a c source file is compiled.
C Compilation process consists of following phases: - first, preprocessor runs through the source code and removes comments, joins lines separated with \ then interprets preprocessor commands (these starting with #) - expands macros and replaces text in a source file that matches macro definitions. Then such preprocessed file is compiled by the compiler into assembly source, that is assembled by an assembler into an object file and finally the object file is linked by linker with libraries or other object files into an executable.


Powered by SMFPacks Menu Editor Mod