0

Hi I am having the following error when tried make libdvm in android 2.3.4 source code,

external/elfutils/libebl/eblobjnote.c:43:17: error: fields must have a constant size: 'variable length array in structure' extension will never be supported
              uint32_t version[descsz / 4 - 1];

this is a genuine c error reported by gcc 4.2 on my mac os x mountain lion. I guess there is some incompability with gcc 4.2 and android 2.3.4 source code. I had to change few things to make the compilation reach this point. I do not know which gcc version was used to compile the code but gcc 4.2 is frequently finding errors in the code.

Can anyone tell me how can I deal with these errors, or in the worst case which gcc version I should use and how can I downgrade to that specific version in mac os x?

P basak
  • 4,874
  • 11
  • 40
  • 63
  • The first release of gcc 4.2 was in May 2007, the last was 4.2.4 in May 2008, so your compiler is a few years out of date. Upgrading to 4.6 or 4.7 may help. I don't recognize the line of code you're showing, and a grep through the sources in "dalvik" and "libcore" in my gingerbread tree didn't find any occurrences of "descsz", so you need to provide more context (e.g. what file is that from). – fadden Oct 17 '13 at 06:12
  • @fadden i already gave the file location see the error, external/elfutils/libebl/eblobjnote.c:43:17 – P basak Oct 17 '13 at 11:44
  • Sorry, you're right, I fixated on "libdvm" for some reason. That's a copy of elfutils (https://fedorahosted.org/elfutils/) for which the "configure" script has been run and an Android.mk provided. It looks like that version is supposed to compile with gcc all the way back to 4.0, so I'm not sure why it's being difficult. – fadden Oct 17 '13 at 13:59
  • Yeah but this is a legitimate error, structs are not allowed to use variable length array. Do u have any idea how I can force gcc to ignore that error during compile time? It seems descsz uses something like num/4-1, do u have any idea how big the num can be? – P basak Oct 17 '13 at 20:49
  • @fadden it seems gcc 4.6 does not generate this error as per the post here, http://stackoverflow.com/questions/14629504/variable-length-array-in-the-middle-of-struct-why-this-c-code-is-valid-for-gcc weird indeed, I am switching to 4.8 and see what happens. – P basak Oct 17 '13 at 20:58

1 Answers1

0

Well, I figured out the problem. Actually CC was linked to clang not gcc, and clang was more restrictive. I used gcc instead of clang and the problem resolved. Although some other compilation errors were there and I believe the project was compiled with gcc older than 4, as the errors I found were reported by gcc.

P basak
  • 4,874
  • 11
  • 40
  • 63