bkerneldev kb.c compile errors

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Lloyd

bkerneldev kb.c compile errors

Post by Lloyd »

hi

i hope this is in the right place other wise im sorry

i am writing my own os using the bkerneldev tutorial on bonafide OS i am trying to compile kb.c from it into my own os

when compiling i get these errors:

lib\kb\kb.c: In function 'keyboard_handler':
lib\kb\kb.c:13: error: parameter 'kbdus' is initialized
lib\kb\kb.c:15: warning: excess elements in scalar initializer
lib\kb\kb.c:15: warning: (near initialization for 'kbdus')
lib\kb\kb.c:15: warning: excess elements in scalar initializer
lib\kb\kb.c:15: warning: (near initialization for 'kbdus')
lib\kb\kb.c:15: warning: excess elements in scalar initializer
lib\kb\kb.c:15: warning: (near initialization for 'kbdus')
lib\kb\kb.c:15: warning: excess elements in scalar initializer
lib\kb\kb.c:15: warning: (near initialization for 'kbdus')
lib\kb\kb.c:15: warning: excess elements in scalar initializer
lib\kb\kb.c:15: warning: (near initialization for 'kbdus')
lib\kb\kb.c:15: warning: excess elements in scalar initializer
lib\kb\kb.c:15: warning: (near initialization for 'kbdus')
lib\kb\kb.c:15: warning: excess elements in scalar initializer
lib\kb\kb.c:15: warning: (near initialization for 'kbdus')
lib\kb\kb.c:15: warning: excess elements in scalar initializer
lib\kb\kb.c:15: warning: (near initialization for 'kbdus')
lib\kb\kb.c:15: warning: excess elements in scalar initializer
lib\kb\kb.c:15: warning: (near initialization for 'kbdus')
.... continues on for every line between 15 - 50
lib\kb\kb.c:50: warning: excess elements in scalar initializer
lib\kb\kb.c:50: warning: (near initialization for 'kbdus')
lib\kb\kb.c:55: error: syntax error before '{' token

i have tried looking around for solutions to this problem but not i have found have worked, and i cannot see what is wrong as the normal bkerneldev compile without the 2 error but still has all the warnings.

i cannot understand why i get the errors.

Lloyd
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:bkerneldev kb.c compile errors

Post by distantvoices »

This post belongs to the osdev forum. here's the testing forum.

I'll take the time later to scan throu that code. Maybe there's some small mistake causing it to bork. :-)
edit:
first, remove the last comma in the initialization of that kbdbus array. It's causing at least one of the errors.

Code: Select all

 0,   /* F11 Key */
    0,   /* F12 Key */
    0,   /* All other keys are undefined */ <-- this line here!!!
};
second, if I am not mistaken, this

Code: Select all

void keyboard_install()
should look like this:

Code: Select all

void keyboard_install(void)
Everything else ... you *do* know c, do you? Becouse on the ohter hand I reckon you get some c knowledge prior to attempting an OS in c. ;-)
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:bkerneldev kb.c compile errors

Post by Solar »

The void is optional.

Erm...

...which compiler, which options? After patching the includes with [tt]extern[/tt] declarations, I was unable to reproduce any errors. I tried [tt]gcc -Wall -c kb.c[/tt] and [tt]gcc -Wall --std=c99 -pedantic -ansi -W -c kb.c[/tt].

(That's gcc 3.3.5)

I'd check the headers involved for any unclosed braces or missing ';'...
Every good solution is obvious once you've found it.
fraserjgordon

Re:bkerneldev kb.c compile errors

Post by fraserjgordon »

Doesn't missing out the void mean that the function takes a variable number of arguments? Void is usually needed to specify no arguments ( in C anyway - in C++ "void function()" is the equivalent of C "void function(void)" )

I may be mistaken however (or working from an old C standard!)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:bkerneldev kb.c compile errors

Post by Solar »

Variable parameter lists are only possible if you specify at least one named parameter, and add an elipsis:

Code: Select all

int printf( char * format, ... )
There might have been some implicitness some decades ago, but not since ISO/ANSI C89 I think.
Every good solution is obvious once you've found it.
fraserjgordon

Re:bkerneldev kb.c compile errors

Post by fraserjgordon »

I checked the ISO C99 (ISO/IEC 9899:1999) specification and it seems we are both right!

According to page 119 (Section 6.7.5.3):
14. An identifier list declares only the identifiers of the parameters of the function. An empty
list in a function declarator that is part of a definition of that function specifies that the
function has no parameters. The empty list in a function declarator that is not part of a
definition of that function specifies that no information about the number or types of the
parameters is supplied
As far as I can tell, the declaration "void function();" declares a function but specifies no type information, so it is similar to (but not the same as) "void function(...);". It does not automatically represent "void function(void);".

When the function is defined, however, "void function()" DOES mean the same as "void function(void)".

This assumes of course that I am reading the statement correctly! Typical standards committee - you need to spend at least 15 minutes figuring out each sentence!

P.S. sorry for starting this off-topic discussion!
Lloyd

Re:bkerneldev kb.c compile errors

Post by Lloyd »

thanks for your help using the information above i have managed to fix the problem
Post Reply