1

Hellow. I have test project with two .c and one .h files. And in this case linter-gcc doesn't see header file.

/* main.c */
#include "module.h"

int main()
{
  f(5);
  return 0;
}

/* module.h */
#ifndef HELLOW
#define HELLOW

void f(int a);

#endif

/* module.c */
#include "module.h"
#include <stdio.h>

void f(int a)
{
  printf("i\n", a);
}

/* CMakeLists.txt is */
cmake_minimum_required(VERSION 2.8)
project(calc-2.4.0)
set(SOURCE_EXE main.c header.c header.h)
add_definitions(-Wall)
add_executable(calc ${SOURCE_EXE})

/* .gcc-flags.json */
{
  "execPath": "/usr/bin/g++",
  "gccDefaultCFlags": "-Wall -c",
  "gccDefaultCppFlags": "-Wall -std=c++11",
  "gccErrorLimit": 15,
  "gccIncludePaths": "..,.,./include,./path",
  "gccSuppressWarnings": true
}

Errors that I see

Error   GCC module.h: No such file or directory 1:10    main.c
Error   GCC module.h: No such file or directory 1:10    module.c

I also can't make lib from .c .h because in real project I have a lot of cross dependences between files. What shall I do to make linter work? Thank you!

Clifford
  • 88,407
  • 13
  • 85
  • 165
EveHo
  • 45
  • 1
  • 5
  • 1
    Please don't post pictures of your IDE, paste the text of code and output and compiler error on your question. – Pablo Apr 29 '18 at 19:47
  • Are all these files placed in the same directory? Try to change #include statement to `#include `. – Ilya Muradyan Apr 29 '18 at 19:59
  • So, I made an error on my answer, that's why I deleted it (so that I can fixed it). I recreated your setup and cmake was able to compile everything. So the question is, are the `.c` files and the `.h` files all in the same directory? What happens when you execute just this `gcc -c main.c -o main.o`? Do you get an error? – Pablo Apr 29 '18 at 20:17
  • Yes, they are in the same directory. I can compile this project successfully, but ptoblem is in the file compile_commands.json that I get by cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 and linter-gcc in atom can't find .h file. – EveHo Apr 29 '18 at 23:39

0 Answers0