0

Bellow is my Makefile from which vscode should understand that the #include "philo.h" and #include "philo_bonus.h" are okay even though those .h files are not in the same folders (srcs and srcs_bonus) as my .c, thanks to the -I include/.

What is very weird is that it behaves in the expected way for my srcs/ files but no for my srcs_bonus/ files which give me the error : cannot open source file "philo_bonus.h"

It does compile well so i assume the issue is vscode's. I have tried reloading the window several times with no differences and this issue has come up accross different projects. Is this a glitch or am I missing something here ?

SRCS        = philo.c               \
              thread.c              \
              util.c                \
              lib.c                 \
              free.c                \
              init.c                \

SRCS_BONUS  = philo_bonus.c         \
              thread_bonus.c        \
              util_bonus.c          \
              lib_bonus.c           \
              free_bonus.c          \
              init_bonus.c          \

OBJS        = $(addprefix srcs/, $(SRCS:.c=.o))

OBJS_BONUS  = $(addprefix srcs_bonus/, $(SRCS_BONUS:.c=.o))

INC         = -I include/

CC          = cc -pthread

AR          = ar rcs

CFLAGS      = -g3 -Wall -Wextra -Werror -fsanitize=address

RM          = rm -f

NAME        = philo

%.o: %.c
    $(CC) $(CFLAGS) $(INC) -c $< -o $@

$(NAME):    $(OBJS)
    $(CC) $(CFLAGS) $(OBJS) -o $(NAME) 

all:        $(NAME)

bonus:      $(OBJS_BONUS)
    $(CC) $(CFLAGS) $(OBJS_BONUS) -o $(NAME)

clean:
    $(RM) $(OBJS) $(OBJS_BONUS)

fclean:     clean
    $(RM) $(NAME)

re:     fclean all

.PHONY:     all bonus clean fclean re

Here is my file tree :

include/ ├─ philo.h ├─ philo_bonus.h srcs/ ├─ files.c srcs_bonus/ ├─ files_bonus.c Makefile

I am on Ubuntu 22.04.1

  • See [1](https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference) and [2](https://stackoverflow.com/q/44142364/589924) – ikegami Feb 08 '23 at 16:49

0 Answers0