Home > Software engineering >  C Same include line in 2 files in the same folder: one works, another can't find the file
C Same include line in 2 files in the same folder: one works, another can't find the file

Time:02-13

Windows 10 Eclipse IDE for C/C Developers Version: Kepler Service Release 2 Build id: 20140224-0627

I'm trying to use imgui. Unfortunately, documentation is pretty shady about how to get it working.

So, in order to get it working, I think I need something called "glad". Whatever it is, the only source of it seems to be some shady-looking one-pager that generates the files for you (found a link to it enter image description here

enter image description here

enter image description here

#include "glad/glad.h"
#include <iostream>
using namespace std;
//for those who wanted to copy default hello world program
int main() {
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    return 0;
}
  1. How is this even possible? Looks like a total nonsense to me. They're in the same folder. Test3 sees the file, glad.c doesn't. I tried replacing "<>" in include in glad.c with quotes like in test3.c, same thing. One file works, another doesn't.
  2. What can I do about it?

CodePudding user response:

Eclipse separates the include paths for C and C files. If you have a program combining both C and C files, the correct include paths need to be set for both languages.

Navigate to the C/C General -> Paths and Symbols -> Includes tab. You will see both languages (and probably Assembly) listed under Languages. Pick the correct language or when adding the path, check the Add to all languages box.

  • Related