Aosp compilation error "use option -std=c99,"

whenever i attempt to build aosp for dragonboard i receive the following error

"external/libdrm/xf86drm.c: In function ‘parse_separate_sysfs_files’:
external/libdrm/xf86drm.c:3102:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (unsigned i = ignore_revision ? 1 : 0; i < ARRAY_SIZE(attrs); i++) {
external/libdrm/xf86drm.c:3102:5: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
external/libdrm/xf86drm.c: At top level:
cc1: warning: unrecognized command line option “-Wno-enum-conversion”
make: *** [out/target/product/db410c/obj/STATIC_LIBRARIES/libdrm_intermediates/xf86drm.o] Error 1
make: *** Waiting for unfinished jobs…
make: *** wait: No child processes. Stop.

make failed to build some targets (03:43 (mm:ss))


i followed the steps here :

i faced an issue in pulling the source code i solved by following instructions here:

i tried adding “ccflags-y := -std=c99” and “LOCAL_CFLAGS += -std=c99” to build/core/ and external/libdrm/ with no success

here’s the output of the make:

This particular error likely comes about because the manifest does not choose specific versions of xf86drm (so it will always adopt the latest one):

I’m not really clear why you can’t fix this by adding -std=c99 to the LOCAL_CFLAGS although perhaps there is a later -std=c89 on the command line that overrides it.

Note also that the instructions you are following are now labelled “old and depreciated”. This is not to say that the new instructions will work for you… they track the latest AOSP which moves fast and sometimes breaks for out-of-tree platforms like DB410C (I know the DB410C broke when Oreo came out… don’t know if it has been looked at since).