Problem with multiple C-files

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problem with multiple C-files

992件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jerre987 on Sat May 11 12:23:47 MST 2013
Hello,

I'm using an LPCXpresso Experiment Board rev PA3 from embedded artists with a LPC1114. I started with a standard project via the project wizard and I have been experimenting with some low level functions. This works fine when I put everything in main.c

Now I've created HardwareConfig.c and HardwareConfig.h for all these low level functions. In main.c I call these functions to initialise the system. When I build the project I get the following errors:

Description Resource Path Location Type
make: *** [multiplecfilesTEST.axf] Error 1 multiplecfilesTEST    C/C++ Problem
undefined reference to `pll_start' main.c /multiplecfilesTEST/src line 64 C/C++ Problem
undefined reference to `system_init' main.c /multiplecfilesTEST/src line 65 C/C++ Problem
undefined reference to `Timer_16Bit_init' main.c /multiplecfilesTEST/src line 66 C/C++ Problem

I've searched the forum already but I 've not been able to fix this, so I hope
someone can help me.

I also have an additional question. Is it possible to use seperate folders for *.c
and the header files and how should these be configured to avoid more linker problems?

Thanks in advance
0 件の賞賛
返信
4 返答(返信)

973件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jerre987 on Sun May 12 04:27:13 MST 2013
Thank you very much R2D2,
It all makes sense to me now, I believed "static"befor a function had a similar meaning as with the declaration of a static variable.

May the force be with you:)
0 件の賞賛
返信

973件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sun May 12 02:54:02 MST 2013
Compiler is doing exactly what you have told him: handling your functions 'static' :) So just delete 'static' in declaration and definition of your HardwareConfig files.


Quote:
[B] Static Functions in C [/B]

  
  By default all functions are implicitly declared as [B]extern[/B], which means they're visible across translation units. But when we use [B]static[/B] it restricts visibility of the function to the translation unit in which it's defined. So we can say[INDENT][COLOR=Red][I]Functions that are visible only to other functions in the same file are known as static functions.[/I][/COLOR][/INDENT]

See: http://codingfreak.blogspot.com/2010/06/static-functions-in-c.html
0 件の賞賛
返信

972件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jerre987 on Sun May 12 01:25:37 MST 2013
Hello,

ok the header folder is working now,but I still have the other errors and some warnings.:confused:  I've attached my project (indeed very simple to export:)).So if you could explain these errors and warnings, this would help me a lot.
0 件の賞賛
返信

972件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sat May 11 12:48:08 MST 2013
Just create a new 'Source Folder' as discussed here: http://knowledgebase.nxp.com/showthread.php?p=24599

Without seeing your project it's difficult to guess what's wrong (there's also a simple Export function in LPCXpresso :)).

Using a 'Source Folder' and adding this folder path to 'Include paths' of project properties is the simplest way to add source and header files to a project.
0 件の賞賛
返信