Code Blocks Separate Compilation Error
Mar 19, 2017 at 6:11pm UTC
So I am in the process of learning C++ and currently learning separate compilation. I am able to include the header file in the source file but I am unable to retrieve a structure deceleration from it.
main.cpp
1 2 3 4 5 6 7
#include <iostream>
#include "Testing.h"
using namespace std;
int main()
{
box wood;
}
Testing.h
1 2 3 4 5 6 7 8 9
#define Testing_H
#ifndef Testing_H
struct box
{
int height;
int width;
};
#endif
"'box' was not declared in this scope" Was the error I received
Here's an image in case that helps.
https://ibb.co/mdLFka
Mar 19, 2017 at 6:26pm UTC
the pre-processor directives should be in this order:
1 2
#ifndef Testing_H
#define Testing_H
Mar 19, 2017 at 6:39pm UTC
It works, thank you very much.
Topic archived. No new replies allowed.