0

I was compiling modem codes with ARM compiler for android phones.
I got the error below:

function "typeof" declared implicitly

Then I though I should use __typeof__. But I got the same error:

function "__typeof__" declared implicitly

I even tried __typeof. But none of them works.

Why?

The compiler is RVDS 5.01. The command line is contained in some scripts.

The error message is:

"/opt2/huanglianjun/PD1401V-modem-1.2.1.c1/boot_images/core/storage/ext4/src/com‌​mon/div64.h", line 47:
Error: #223-D: function "typeof" declared implicitly.

The code is :

#define do_div(n,base) do{  \ 
      uint32_t __base = (base); \ 
      uint32_t __rem;   \ 
      (void)(((typeof((n)) *)0) == ((uint64_t *)0));    \ 
      if (((n) >> 32) == 0) {   \ 
          __rem = (uint32_t)(n) % __base;   \ 
          (n) = (uint32_t)(n) / __base; \ 
      } else    \ 
          __rem = __div64_32(&(n), __base); \ 
          __rem;    \ 
    }while(0)
Quentin
  • 62,093
  • 7
  • 131
  • 191
user1651758
  • 145
  • 12
  • 2
    Perhaps your particular compiler does not support the typeof extension. Show us some relevant info: 1. Your compiler name and version. 2. The command line used to compile your code. 3. The exact error message you get. And preferrably 4. The code you compile, a minimal code example that shows the same error. – nos Aug 13 '15 at 07:59
  • The compiler is RVDS 5.01. The command line is contained in some scripts. The error message is: "/opt2/huanglianjun/PD1401V-modem-1.2.1.c1/boot_images/core/storage/ext4/src/common/div64.h", line 47: Error: #223-D: function "typeof" declared implicitly. The code is #define do_div(n,base) do{ \ uint32_t __base = (base); \ uint32_t __rem; \ (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \ if (((n) >> 32) == 0) { \ __rem = (uint32_t)(n) % __base; \ (n) = (uint32_t)(n) / __base; \ } else \ __rem = __div64_32(&(n), __base); \ __rem; \ }while(0) @nos – user1651758 Aug 13 '15 at 08:09
  • What compiler flags are you using? A manual I found suggests that RVDS supports some GCC extensions including `typeof`, unless `--strict-ansi` or `-ps` is given. – nemetroid Aug 13 '15 at 08:20
  • 2
    I believe some versions of RVDS requires the --gnu flag to enable some of the gcc extension – nos Aug 13 '15 at 08:27

1 Answers1

2

If I read the documentation right, typeof is supported since at least RVDS 3.0, but you need to enable GNU mode by passing the --gnu flag to armcc.

Quentin
  • 62,093
  • 7
  • 131
  • 191