Open
Description
Observed behavior
I have actually two problems with this config, so please tell me if I should break this issue into smaller once.
I am trying to reassemble this simple directory structure
├── include
│ ├── my_lib.h
│ └── my_lib
│ └── common.h
├── src
│ └── my_lib.c
└── .ccls
My project use XCB and FreeType, so I included those into my .ccls
as well
gcc
-std=c99
-Iinclude
%c -lxcb
%c -lxcb-randr
%c `pkg-config --cflags freetype2`
%c `pkg-config --libs freetype2`
Expected behavior
I can't get my source directory to see include files.
Second problem is that ccls does seem to recognize the freetype2/ft2build.h
header but types and functions defined by it (e.g. FT_Library
) are reported as undeclared.
Steps to reproduce
- For a minimal reproducible example go
mkdir include src
- Create
.ccls
file in root directory
gxx
-xc
-std=c99
-Iinclude
%c `pkg-config --cflags freetype2`
%c `pkg-config --libs freetype2`
- Add CMakeLists.txt to root directory
cmake_minimum_required(VERSION 3.16)
project(test VERSION 0.1.0)
set(CMAKE_C_STANDARD 99)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_C_STANDARD_REQUIRED YES)
set(CMAKE_C_EXTENSIONS OFF)
find_package(Freetype REQUIRED)
add_executable(${PROJECT_NAME} src/main.c)
target_link_libraries(${PROJECT_NAME}
PRIVATE
${FREETYPE_LIBRARIES})
target_include_directories(${PROJECT_NAME}
PRIVATE
include
${FREETYPE_INCLUDE_DIRS})
- Add the include header
// include/test.h
#ifndef _TEST_H
#define _TEST_H
extern int value = 665;
#endif // _TEST_H
- And finally add a source file
// src/main.c
#include "test.h"
#include <freetype2/ft2build.h>
#include FT_FREETYPE_H
#include "stdio.h"
#include <stddef.h>
static FT_Library ft = NULL;
int main(void) {
printf("value: %i\n", value);
return 0;
}
System information
- clang version: 0.20240202-1
- OS: Arch Linux
- Editor: Emacs (nvim gives me the same result)
- Language client (and version): emacs-ccls 20240331.2132
Metadata
Metadata
Assignees
Labels
No labels