News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Let MinGW throw Code::Blocks generate assembly code (without errors)

Started by unnaturhal, April 20, 2013, 12:40:35 PM

Previous topic - Next topic

unnaturhal

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.

stefanos_

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.

stahta01

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

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

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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

stefanos_

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.


gcc -ansi -Wall -g -S file.c
gcc -c file.s -o file.o
gcc file.o -o file

unnaturhal

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.

osdt

Quote from: unnaturhal on April 20, 2013, 12:40:35 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

Jenna

Quote from: unnaturhal on April 20, 2013, 06:30:45 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.

unnaturhal

Quote from: jens on April 20, 2013, 06:56:51 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!