z88dk forums

z80 Development Kit

You are not logged in.

#1 2007-06-24 12:33:58

Dylan Smith
Guest

[Z88dk-users] Multiple modules

Hi all,

What am I doing wrong here?

If I have two modules, say:
main.c
foo.c

and foo.c has a function 'int foo(int bar);'
all declared in foo.h (which is included in foo.c) - why do I get this
error when compiling main.c to an object file (not linking!)

1 errors occurred during assembly
Errors in source file main.c:
File '/tmp/tmpXXrLYKVQ.opt', Module 'MAIN', at line 80, Symbol not defined

But if I have a function called 'int foo()' (note, no arguments) in the
same arrangement, it compiles and links fine?

What do I need to do to be able to pass arguments to functions in other C
files?

Cheers.
--
Dylan Smith, Port St Mary, Isle of Man    | Code fast, crash young and
Flying: http://www.dylansmith.net         | leave a beautiful core.
FFE/Elite Universe: http://www.alioth.net |             -- JK (#afe)


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

 

#2 2007-06-24 15:45:00

dom
Administrator
Registered: 2007-07-15
Posts: 738
Website

Re: [Z88dk-users] Multiple modules

On Sun, 24 Jun 2007, Dylan Smith wrote:

and foo.c has a function 'int foo(int bar);'
all declared in foo.h (which is included in foo.c) - why do I get this
error when compiling main.c to an object file (not linking!)

It needs to be extern int foo(int bar) in the header file, i.e. the extern
scoping is compulsory.

d.



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson