Author Topic: Let MinGW throw Code::Blocks generate assembly code (without errors)  (Read 8539 times)

Offline unnaturhal

  • Multiple posting newcomer
  • *
  • Posts: 20
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_

  • Guest
Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
« Reply #1 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.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
« Reply #2 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

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++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

stefanos_

  • Guest
Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
« Reply #3 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
« Last Edit: April 20, 2013, 06:00:16 pm by stefanos_ »

Offline unnaturhal

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
« Reply #4 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.

Offline osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
« Reply #5 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

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
« Reply #6 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.

Offline unnaturhal

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Let MinGW throw Code::Blocks generate assembly code (without errors)
« Reply #7 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!