<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>About file path in the header file</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72820/about-file-path-in-the-header-file</link><description>Hi I am the user of zephyr and nrf connect SDK in ubuntu 20.04. one question about file path in the header file. for instance, the demonstration &amp;quot;nrf/samples/zigbee/light_switch &amp;quot;. #include &amp;lt;zboss_api.h&amp;gt; #include &amp;lt;zboss_api_addons.h&amp;gt; #include &amp;lt;zigbee</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 21 Mar 2021 03:10:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72820/about-file-path-in-the-header-file" /><item><title>RE: About file path in the header file</title><link>https://devzone.nordicsemi.com/thread/301060?ContentTypeID=1</link><pubDate>Sun, 21 Mar 2021 03:10:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a460398d-0419-4978-9e0a-45c932dbea18</guid><dc:creator>len00x</dc:creator><description>&lt;p&gt;&lt;span&gt;Dear&amp;nbsp;Edvin&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This is very useful for my research.&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Thank you so much for responding to my question.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About file path in the header file</title><link>https://devzone.nordicsemi.com/thread/300135?ContentTypeID=1</link><pubDate>Tue, 16 Mar 2021 13:02:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc0ac85f-6432-4aec-845e-1f5e7845f2fe</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The NCS (nRF Connect SDK) is based on CMake, so the include folders are basically set up to include the entire SDK, so all you need to do to include a header file from the SDK is to use #include.&lt;/p&gt;
&lt;p&gt;If you want to know where this folder is located, you can just search for it in the NCS sdk.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to create a new header file, and place it in a folder, you need your project to include this folder, like it is done in the other CMakeLists.txt.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I can use the peripheral_uart example found in ncs\nrf\samples\bluetooth\peripheral_uart as an example.&lt;/p&gt;
&lt;p&gt;First, create a folder next to the src folder called custom_files:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1615899386250v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;inside your custom_files folder, create two folders, one called &amp;quot;src&amp;quot; and one called &amp;quot;include&amp;quot;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To add this include folder to the list of folders that the compiler will look for header files, open the CMakeLists.txt, and add:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;zephyr_library_include_directories(custom_files/include)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;right after&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;zephyr_library_include_directories(.)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Then create two files:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;test_file.h in your include folder, and test_file.c in your src folder.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;After that, go back to the CMakeLists.txt, and locate the target_sources() call.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Add your custom .c file:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;# NORDIC SDK APP START
target_sources(app PRIVATE
  src/main.c;
  custom_files/src/test_file.c
)&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Now you can include the header file from your main.c file using &amp;quot;#include &amp;quot;test_file.h&amp;quot;, and if you declare a function in that file, define it in the .c file, you can use it from main.c.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Attaching my test files here:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/test_5F00_file.h"&gt;devzone.nordicsemi.com/.../test_5F00_file.h&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/test_5F00_file.c"&gt;devzone.nordicsemi.com/.../test_5F00_file.c&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;using the test_function() from main will print &amp;quot;test_function&amp;quot; over UART.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Edvin&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>