
Originally Posted by
Jayes
I doubt if that iwould make any difference. Whatever the order, when the errors occur those includes have all been included.
It does make a difference. Consider the following example:
// file1.h
#ifndef X
#define X int
#endif
// file1.h
#ifndef X
#define X int
#endif
To copy to clipboard, switch view to plain text mode
// file2.h
#ifndef X
#define X std::string
#endif
// file2.h
#ifndef X
#define X std::string
#endif
To copy to clipboard, switch view to plain text mode
and then two orders of inclusion:
// main.cpp
#include "file1.h"
#include "file2.h"
//...
X x;
// main.cpp
#include "file1.h"
#include "file2.h"
//...
X x;
To copy to clipboard, switch view to plain text mode
// main.cpp
#include "file2.h"
#include "file1.h"
// ...
X x;
// main.cpp
#include "file2.h"
#include "file1.h"
// ...
X x;
To copy to clipboard, switch view to plain text mode
Now in version 1 "x" will be of type "int" but in version 2 it will be of type "std::string". So the order may matter (in a place AFTER the files have been included - when "x" is declared).
Try reordering the includes and try to substitute all the includes you can with forward declarations.
Bookmarks