this post was submitted on 12 Jul 2023
6 points (100.0% liked)

VIM - Vi Improved

28 readers
1 users here now

VIM - Vi Improved, text editor community

Please use English.

founded 4 years ago
MODERATORS
 

Solution:

  1. Make all command substition in a make done through the assignment operator e.g.
cflags != pkg-config --cflags gtk4
libs != pkg-config --libs gtk4

all:
	gcc $(cflags) -o watch main.c $(libs)

not

all:
	gcc $$(pkg-config --cflags gtk4) -o watch main.c $$(pkg-config --libs gtk4)
  1. add this to your .vimrc: let g:ale_c_parse_makefile = 1

ALE gives me a warning when I use gtk

#include <gtk/gtk.h> /* E: gtk/gtk.h: No such file or directory

This is probably happening because ALE isn't using my compiler flags gcc $( pkg-config --cflags gtk4 ) -o program main.c $( pkg-config --libs gtk4 ) that I stole from the gtk documentation. These compiler flags allow gcc to find gtk/gtk.h even though it is in gtk-4.0/gtk/gtk.h

How do I make ALE aware of my compiler flags?

top 3 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 1 year ago (1 children)
[–] [email protected] 1 points 1 year ago (1 children)

I saw that but where do I put compile_commands.json? It isn't working

my compile_commands.json for reference:

[
	{ "directory": "/home/user/watch",
		"command": "/usr/bin/gcc $( pkg-config --cflags gtk4 ) -o program main.c $( pkg-config --libs gtk4 )",
		"file": "main.c" }
]
[–] [email protected] 1 points 1 year ago

Seems like you solved it with the Makefile option but it is odd that compile_commands.json is not parsed (I can confirm this on my machine). Anyway thanks for providing a solution :)