include in project header file result in error

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
FaBi_2763241
Level 4
Level 4
10 likes given 5 likes given First like received

Hello all,

when I build a project with PSOC 6 I have 127 build errors saying that #include is nested too deeply in project.h

what on earth could be going on?

Any idea what circumstances cause this to happen?

Thanks.

PS see attached output during build.

0 Likes
1 Solution
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

I can reproduce the issue by creating a custom component.

1) Create a component without pins.

GS004278.png

2) Add a header file to the component as follows.

#include "project.h"

extern uint32_t `$INSTANCE_NAME`_global_variable;

Declare a global variable.  project.h is included to use the uint32_t type.

3) Add a C file to the component as follows.

#include "`$INSTANCE_NAME`.h"

uint32_t `$INSTANCE_NAME`_global_variable;

Define a global variable body.

4) Put the component instance on a top level schematic.

GS004279.png

5) Build the project and got huge number of error.

GS004280.png

I have two solutions.

Solution 1)

In the header file, include "stdin.h" instead of "project.h"

#include <stdint.h>

extern uint32_t `$INSTANCE_NAME`_global_variable;

Solution 2)

In the header file, add #ifdef structure to prevent recursive inclusion.

#if !defined(`$INSTANCE_NAME`_H)

#define `$INSTANCE_NAME`_H

#include "project.h"

extern uint32_t `$INSTANCE_NAME`_global_variable;

#endif  /* End `$INSTANCE_NAME`_H */

It is better to combine both solutions.

#if !defined(`$INSTANCE_NAME`_H)

#define `$INSTANCE_NAME`_H

#include <stdint.h>

extern uint32_t `$INSTANCE_NAME`_global_variable;

#endif  /* End `$INSTANCE_NAME`_H */

This can reduce the number of header file inclusion to reduce the compile time.

Regards,

Noriaki

View solution in original post

6 Replies
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

Please check the content of the project.h file.

There should be #include line to include the project.h file directly or indirectly.

Regards,

Noriaki

0 Likes
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

I can reproduce the issue by creating a custom component.

1) Create a component without pins.

GS004278.png

2) Add a header file to the component as follows.

#include "project.h"

extern uint32_t `$INSTANCE_NAME`_global_variable;

Declare a global variable.  project.h is included to use the uint32_t type.

3) Add a C file to the component as follows.

#include "`$INSTANCE_NAME`.h"

uint32_t `$INSTANCE_NAME`_global_variable;

Define a global variable body.

4) Put the component instance on a top level schematic.

GS004279.png

5) Build the project and got huge number of error.

GS004280.png

I have two solutions.

Solution 1)

In the header file, include "stdin.h" instead of "project.h"

#include <stdint.h>

extern uint32_t `$INSTANCE_NAME`_global_variable;

Solution 2)

In the header file, add #ifdef structure to prevent recursive inclusion.

#if !defined(`$INSTANCE_NAME`_H)

#define `$INSTANCE_NAME`_H

#include "project.h"

extern uint32_t `$INSTANCE_NAME`_global_variable;

#endif  /* End `$INSTANCE_NAME`_H */

It is better to combine both solutions.

#if !defined(`$INSTANCE_NAME`_H)

#define `$INSTANCE_NAME`_H

#include <stdint.h>

extern uint32_t `$INSTANCE_NAME`_global_variable;

#endif  /* End `$INSTANCE_NAME`_H */

This can reduce the number of header file inclusion to reduce the compile time.

Regards,

Noriaki

Hello Noriaki

I will test your suggestions later and report back here.

many thanks.

Fausto

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Noriaki

yes, following your method the error has disappeared.

I have another question, less critical.

How could I avoid these info messages related to pins which happen only with PSOC 6 during build?

0 Likes

Do you mean the Notes messages like this?

GS004292.png

Actually I don't know.

I see these messages disappeared when the "Programming\Debugging>Debug Selection" option is set to "GPIO" in the "System" tab of the "Design Wide Resource"  but I don't think this is a solution what your are expecting.

Regards,

Noriaki

0 Likes

They are not errors or warning, so the code still compiles okay. I was just wondering if there is a note somewhere in PSOC 6 documentation that mentions these build messages.

Regards

Fausto

0 Likes