Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 21994

makefile fails when creating object file for inner directory

$
0
0

In the current directory I have the following files:

election.c election.h extended_map.c extended_map.h main.c test_utilities.c utilities.c utilities.h

Plus I have an inner folder inside the current one called mtm_map which includes map.c map.h

I have created a makefile which works fine when running:

make main.omake extended_map.omake election.omake utilities.omake clean

but fails when running:

-bash-4.2$ make map.occ    -c -o map.o map.cmap.c: In function ‘getIndexOfKey’:map.c:36:5: error: ‘for’ loop initial declarations are only allowed in C99 mode     for (int i = 0; i < map->size; i++)     ^map.c:36:5: note: use option -std=c99 or -std=gnu99 to compile your codemap.c: In function ‘initializeElements’:map.c:59:5: error: ‘for’ loop initial declarations are only allowed in C99 mode     for (int i=initial_index;i<last_index;i++)     ^map.c: In function ‘mapCopy’:map.c:165:5: error: ‘for’ loop initial declarations are only allowed in C99 mode     for (int i = 0; i < map->size; i++)     ^map.c: In function ‘mapGet’:map.c:239:5: error: ‘for’ loop initial declarations are only allowed in C99 mode     for (int i = 0; i < map->size; i++)     ^make: *** [map.o] Error 1

makefile:

CC = gccOBJS = main.o ./mtm_map/map.o extended_map.o election.o utilities.oEXEC = electionDEBUG_FLAG = -DNDEBUGCOMP_FLAG = -std=c99 -Wall -pedantic-errors -Werror$(EXEC) : $(OBJS)    $(CC) $(DEBUG_FLAG) $(OBJS) -o $@main.o: main.c ./mtm_map/map.h election.h test_utilities.h    $(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.cmap.o: ./mtm_map/map.c ./mtm_map/map.h utilities.h    $(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.cextended_map.o: extended_map.c extended_map.h ./mtm_map/map.h utilities.h    $(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.celection.o: election.c election.h ./mtm_map/map.h extended_map.h utilities.h    $(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.cutilities.o: utilities.c utilities.h    $(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.cclean:    rm -f $(OBJS) $(EXEC)

Any suggestions on how to fix that? Please Note I want map.o to be created inside the current directory (not inside mtm_map)


Viewing all articles
Browse latest Browse all 21994

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>