disappearing #includes

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

cross mob
JiAs_4080261
Level 1
Level 1
5 replies posted First reply posted First question asked

OK, I am feed up with having to add back about 15 lines of  #includes of my personal functions in the form of #include statements to the bottom of the project.h file.

Most of the time everything is fine and the #includes are still there.

But the other times they disappear and cause errors.

I have saved all after adding the #include statement.

I have tried to place the #includes in the main.c file but they do not work as expected, I have found they only work in the project.h file.

I believe this mostly happens when I change the TopDesign.cysch design.

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Reading this discussion, I wonder if you specified the include directories in the Build Settings?

One of the bad behavior of PSoC Creator is that even we include a header in the project, the project does not recognize the include directory for that file.

So we need to specify or add that include file in the Build Settings.

For example, one of my sample has relatively "many" files (headers and sources)

Re: MCU Tester, a Swiss Army Knife for PSoC (CY8CKIT-044 version)

And since I don't want to place too many files in the flat project folder,

I reorganized the folder structure like below

=======================

<project folder>/

codegentemp/

CortexM0/

Export/

Generated_Source/

sources/ <--- folder for additional sources and headers

TopDesign/

CLEAN.log

cyapicallbacks.h

func_list.c

func_list.h

main.c

...

<project>.cyprj

...

REBUILD.log

souces/

adc/

adc_utils.c

adc_utils.h

gpio/

gpio_utils.c

gpio_utils.h

i2c/

i2c_api_utils.c

i2c_api_utils.h

i2c_utils.c

i2c_utils.h

mem/

mem_utils.c

mem_utils.h

pwm/

pwm_utils.c

pwm_utils.h

spi/

spi_utils.c

spi_utils.h

tty/

tty_utils.c

tty_utils.h

=======================

Workspace Explorer shows

Note: I added "folders" manually and organized the files manually.

         But this does not let PSoC Creator know where those headers are

         even it recognizes where those sources files are....

001-workbench.JPG

So I needed to specify include directories by using "Build Settings"

I usually open it from right-click the project name -> Build Settings... like below,

but you can also invoke it from the menu Project > Build Settings...

002-build-settings.JPG

In the Build Settings dialog, select <project> / ARM GCC... / Compiler

Then we can see "Additional Inlucde Directories" in the "General" section.

003-build-settings-compiler.JPG

To modify (add/remove) directories, click the right side [...] button in the Additonal Include Directories

004-include-pathes.JPG

Then use [New] [Remove] [Down] [Up] buttons to add and prioritize your include directories

006-pathes.JPG

Hopefully, by doing this may improve your situation. (fingers crossed)

moto

P.S. I agree with Len-san about including a source file instead of a header.

Once I saw a user who had problems by including a source file.

I also recommend you to make it a header file or add a header file for that source file

and only include the header file.

View solution in original post

0 Likes
16 Replies