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?

  • gun/linux@latte.isnot.coffeeOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    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" }
    ]
    
    • nachtigall@feddit.de
      link
      fedilink
      English
      arrow-up
      1
      ·
      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 :)