Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: unnaturhal on April 20, 2013, 12:40:35 pm

Title: Let MinGW throw Code::Blocks generate assembly code (without errors)
Post by: unnaturhal on April 20, 2013, 12:40:35 pm
Hi there!
I have a simple problem. I need to generate assembly code when I compile my source, so I find that I must add -S suffix to the compiler.
I got it (in (right_click_on)Project -> Build options... -> Compiler settings -> Other options), simply writing -S in the Other options panel.
Now, when I rebuild my project, it automatically opens a main.o blank file and gives a syntax error in the Biuld messages panel. But, when I try to open the .o files, the assembly code is there, so it seems to work.
The question is: why Code::Blocks gives back this error and have this strange behavior? And again, there is a way to solve this problem?

Thanks in advance.
Title: Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
Post by: stefanos_ on April 20, 2013, 03:07:52 pm
This is totally unrelated to Code::Blocks IDE. This is something that has to do with your compiler; just run "gcc demo.c -S" from terminal and you will be just fine.
Title: Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
Post by: stahta01 on April 20, 2013, 03:33:08 pm
This is totally unrelated to Code::Blocks IDE. This is something that has to do with your compiler; just run "gcc demo.c -S" from terminal and you will be just fine.

I am NOT sure the question is totally unrelated to Code::Blocks IDE.

You might try fixing it by changing the file property setting in the Code::Blocks IDE.
But, I would likely try doing something like suggested here http://wiki.codeblocks.org/index.php?title=Adding_support_for_non_C/C%2B%2B_files_to_the_build_system (http://wiki.codeblocks.org/index.php?title=Adding_support_for_non_C/C%2B%2B_files_to_the_build_system)

NOTE: That is likely over complex for you.
Using a post or post build step is likely what would be simplest for you.

Tim S.
Title: Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
Post by: stefanos_ on April 20, 2013, 05:56:37 pm
Even though initially I said it's not related (and I still believe it's not fully related) with Code::Blocks, it is rather related to compiler; I haven't found though a decent way to produce the desired results you want with the help of Code::blocks. I do know the traditional way of using the compiler itself from terminal.

Code
gcc -ansi -Wall -g -S file.c
gcc -c file.s -o file.o
gcc file.o -o file
Title: Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
Post by: unnaturhal on April 20, 2013, 06:30:45 pm
Thanks for the replies but this morning I upgraded my Code::Blocks (from 10.05 to 12.11) and my MinGW, and now it desn't compile nothing (and put a red line under comments and strings without a reason..).
I will try your methods when I will solve those issues.
Title: Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
Post by: osdt on April 20, 2013, 06:45:50 pm
... I have a simple problem. I need to generate assembly code when I compile my source, so I find that I must add -S suffix to the compiler.
... But, when I try to open the .o files, the assembly code is there, so it seems to work. ...
The question is: what are you trying to do?
a) Generate ASM code seems to work, except for the extension (*.o)
b) use these generated files and compile/link them afterwards

For a: create a custom compiler and set 'Object file extension' to 'S', you're done.
For b: will be tricky but doable.

- osdt
Title: Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
Post by: Jenna on April 20, 2013, 06:56:51 pm
[...] and put a red line under comments and strings without a reason [...]

It has a reason (of course), searching the forum would possibly give you the correct answer:
it's the (new,at least to 12.11 against 10.05) spellchecker-plugin.
Either disable it totally, disable online spellchecking or install and setup correct dictionaries.
Title: Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
Post by: unnaturhal on April 20, 2013, 07:08:37 pm
It has a reason (of course), searching the forum would possibly give you the correct answer:
it's the (new,at least to 12.11 against 10.05) spellchecker-plugin.
Either disable it totally, disable online spellchecking or install and setup correct dictionaries.
Wow, amazing :) thanks jens!