[clangd] add cmake files and guide for clangd usage
This commit is contained in:
2
.clangd
2
.clangd
@@ -1,2 +1,2 @@
|
|||||||
CompileFlags:
|
CompileFlags:
|
||||||
Add: [-std=c23]
|
CompilationDatabase: build
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -86,3 +86,5 @@ dkms.conf
|
|||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
|
||||||
|
.cache/
|
||||||
|
build/
|
||||||
|
|||||||
9
CMakeLists.txt
Normal file
9
CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
project(pracitces)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 23)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
set(GLOBAL_INCLUDES ${CMAKE_SOURCE_DIR}/include)
|
||||||
|
|
||||||
|
add_subdirectory(practice-1)
|
||||||
12
README.md
12
README.md
@@ -1,3 +1,13 @@
|
|||||||
# practices
|
# practices
|
||||||
|
|
||||||
Repository with code from practice sessions
|
Repository with code from practice sessions
|
||||||
|
|
||||||
|
# Clangd
|
||||||
|
First, build the project to generate `compile_commands.json`:
|
||||||
|
```bash
|
||||||
|
cmake -B build
|
||||||
|
```
|
||||||
|
Then tell clangd where to find it by adding to `.clangd`:
|
||||||
|
```yaml
|
||||||
|
CompileFlags:
|
||||||
|
CompilationDatabase: build
|
||||||
|
```
|
||||||
3
include/add.h
Normal file
3
include/add.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
int32_t add(int32_t a, int32_t b);
|
||||||
2
practice-1/CMakeLists.txt
Normal file
2
practice-1/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
add_executable(practice-1 main.c)
|
||||||
|
target_include_directories(practice-1 PRIVATE ${GLOBAL_INCLUDES})
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct my_perfect_float
|
struct my_perfect_float
|
||||||
@@ -32,7 +32,6 @@ struct dm
|
|||||||
int32_t mod;
|
int32_t mod;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int divmod(int32_t x, int32_t y, struct dm* dm)
|
int divmod(int32_t x, int32_t y, struct dm* dm)
|
||||||
{
|
{
|
||||||
int aa = 2; // initialization
|
int aa = 2; // initialization
|
||||||
|
|||||||
Reference in New Issue
Block a user