Shashank M
Shashank M

Reputation: 1

How to include header file in IAR workbench studio?

I have created group in IAR IDE and I have added the .h file, but still it is showing error like source file not found. How do I add header file in IAR?

img

I also tried adding path in preprocessor as $PROJ_DIR$/hdr. But still I'm getting same error.

Upvotes: 0

Views: 1800

Answers (1)

user694733
user694733

Reputation: 16039

I have created group in IAR IDE and I have added the .h file, but still it is showing error like source file not found.

Adding header files to source tree is only for convenience. It won't help the compiler to find the header file. Also, the group name has no real correlation to any folder on disk.

I also tried adding path in preprocessor as $PROJ_DIR$/hdr.

That won't work because IDE environment variables like $PROJ_DIR$ are not recognized in the source code.

How do I add header file in IAR?

Go to project options and add your path of your header folder in C/C++ Compiler -> Preprocessor -> Additional include directories. This will make sure that compiler scans the directory were your header is when including the file. You can use $PROJ_DIR$ relative paths here.

Upvotes: 5

Related Questions