Page 1 of 1
cannot compile c code or use ld
Posted: Sun Aug 09, 2009 11:41 am
by sainsbm
Hi,
I am pretty new to microcoding, but I cant seem to get c code to compile using mingw. i am using the command line
, but it always returns some sort of error, for example " 'u32int' undeclared" with the line:
Code: Select all
static void play_sound(u32int nFrequence) {
.
Also, I can't use the ld command in any way, it always returns: (filename).o unrecognised file format.
Thanks for any help!
Re: cannot compile c code or use ld
Posted: Sun Aug 09, 2009 1:31 pm
by ru2aqare
sainsbm wrote:Hi,
I am pretty new to microcoding, but I cant seem to get c code to compile using mingw. i am using the command line
, but it always returns some sort of error, for example " 'u32int' undeclared" with the line:
Code: Select all
static void play_sound(u32int nFrequence) {
.
Also, I can't use the ld command in any way, it always returns: (filename).o unrecognised file format.
Thanks for any help!
Your C compiler reports an error because the identifier "u32int" has not been declared when it reaches the offending line. You need to provide a definition for it, for example
Code: Select all
# for msvc
typedef unsigned __int32 u32int;
# for gcc - i'm not sure
typedef unsigned int u32int;
Re: cannot compile c code or use ld
Posted: Sun Aug 09, 2009 2:25 pm
by sainsbm
ru2aqare wrote:Your C compiler reports an error because the identifier "u32int" has not been declared when it reaches the offending line. You need to provide a definition for it, for example
Code: Select all
# for msvc
typedef unsigned __int32 u32int;
# for gcc - i'm not sure
typedef unsigned int u32int;
thanks, ill try that, but its a code sample from the wiki, i assumed they would define the datatypes they use...
Re: cannot compile c code or use ld
Posted: Sun Aug 09, 2009 2:39 pm
by ru2aqare
sainsbm wrote:
thanks, ill try that, but its a code sample from the wiki, i assumed they would define the datatypes they use...
I don't think you're supposed to copy-paste code from any wiki and expect it to magically work...
Re: cannot compile c code or use ld
Posted: Sun Aug 09, 2009 5:02 pm
by Combuster
I also think you are
supposed to know the language you program in
Re: cannot compile c code or use ld
Posted: Sun Aug 09, 2009 5:48 pm
by gravaera
sainsbm wrote:ru2aqare wrote:Your C compiler reports an error because the identifier "u32int" has not been declared when it reaches the offending line. You need to provide a definition for it, for example
Code: Select all
# for msvc
typedef unsigned __int32 u32int;
# for gcc - i'm not sure
typedef unsigned int u32int;
thanks, ill try that, but its a code sample from the wiki, i assumed they would define the datatypes they use...
This maybe a little off, but I think that sounded a little presumptious. You should be glad that something like an Operating System Development Wiki even exists. We're not exactly completely out of the dark ages of people sitting in dark, damp corners in basements chewing hard on pencils and tapping away at frustrating code without any support whatsoever.
It's interesting how people take stuff for granted. I remember being more than extraordinarily surprised to find a whole
community of people offering resources to OSDevers.
Re: cannot compile c code or use ld
Posted: Sun Aug 09, 2009 6:11 pm
by Kitsune
sainsbm wrote:ru2aqare wrote:Your C compiler reports an error because the identifier "u32int" has not been declared when it reaches the offending line. You need to provide a definition for it, for example
Code: Select all
# for msvc
typedef unsigned __int32 u32int;
# for gcc - i'm not sure
typedef unsigned int u32int;
thanks, ill try that, but its a code sample from the wiki, i assumed they would define the datatypes they use...
The code on the wiki is generally always just a snippet, given in a context to help you better understand the concept it's trying to convey, not in a context to be able to be simply dropped into a project.
Some of the tutorials will hold your hand the entire way, but a lot of them will make assumptions about what you already know.
(and for GCC it is indeed
typdef unsigned int u32int;... you can simply drop that in a common header file and be fine)
Re: cannot compile c code or use ld
Posted: Mon Aug 10, 2009 1:48 am
by sainsbm
Kitsune wrote:
Some of the tutorials will hold your hand the entire way, but a lot of them will make assumptions about what you already know.
(and for GCC it is indeed typdef unsigned int u32int;... you can simply drop that in a common header file and be fine)
Regarding the others first, Im sorry if I presumed too much of that code sample.
You see, I've gon through all the beginner tutorial's here, including the baby steps one, but I always get stuck after the "Hello World!" bootloaders when you start to integrate c code. gcc reports errors for anything I try to compile with the tutorials, and then ld always doesnt recognise .o files. It's just getting kinda frustrating cause Hello world is the limit I am able to compile!
To someone else: I used to do c++ and assumed that the syntax would be pretty similar (as long as you dont use advanced c++ things)
Sorry if I'm being dumb, and thanks for your help