visual studio – Unable to include headers into C++ on VS Code


I noticed an error in a program when I tried to organize my code with the help of headers. I’ve been stuck for a minute on it so I tried the bare minimum just to see if it would run and it keeps saying

“D:/C++ projects/Testing header/test.cpp:6:(.text+0xe): undefined reference to `printThing()'”

Here’s all of the programs I am using for this test:

test.cpp

#include<iostream>
#include "header.h"

int main()
{
   printThing(); 
   return 0;
}

header.h

#ifndef _header_h
#define _header_h

void printThing();

#endif //_header_h

header.cpp

#ifndef _header_h
#define _header_h

void printThing();

#endif //_header_h

I mean I don’t really know what to do, I’m suspecting there’s an issue with the compiler or VS Code of some sort but I’m not sure where to start. Also I receive no errors before running the program, no red outlines or such.

Leave a Reply

Your email address will not be published. Required fields are marked *