File Inclusion: Multiple files with the same name and function

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

File Inclusion: Multiple files with the same name and function

256 次查看
karmegancjk
Contributor III

Hi,

I have MATLAB-generated .c and .h files included in my S32DS IDE application project.

In this project, I have separate application and library files for each timing interval: 1 ms, 10 ms, 50 ms, and 100 ms.

Each of these timing-based libraries (e.g., 1 ms, 10 ms, etc.) contains files like rte.c/.h and rtd_init.c/.h. These files include a function with the same signature, for example:

void get(uint8_t a);

So, in:

  • 1 ms: rte.c/.h and rtd_init.c/.h → contains void get(uint8_t a);

  • 10 ms: rte.c/.h and rtd_init.c/.h → also contains void get(uint8_t a);

  • 50 ms: same structure and function

  • 100 ms: same structure and function

The problem is, while building the project, I get multiple definition errors, since the same function (get) with the same name exists in multiple libraries.

What I want is:

  • If I’m calling a 1 ms function, it should use only the 1 ms version of rte.c/.h and rtd_init.c/.h

  • If calling a 10 ms function, it should use only the 10 ms version of those files

But right now, I cannot include them conditionally like this.

Is there any configuration setting, build setup, or recommended method in S32DS to manage this kind of situation where multiple libraries contain same-named files and functions?

thanks and Regards,

Karmegan C.

标记 (2)
0 项奖励
回复
1 回复

229 次查看
stanish
NXP Employee
NXP Employee

Hello Karmegan, 

I can imagine you create a separate build configuration per each timing interval.

stanish_0-1756126047525.png

The output executable  (.elf) would only consist from 1ms methods and 1ms lib. Similarly to other timing configurations

In order to avoid multiple definition errors you can exclude all others .c files and libraries from the build configuration. See below the Build Configuration Explorer you can use to select source to be used by the specific build configuration. Excluded sources are crossed and grayed in the project manager View.

 

stanish_2-1756126624776.pngstanish_1-1756126462121.png

If it does not meet your need please specify your goal more in the details.

Hope it helps.

Stan

 

0 项奖励
回复