-Ec: Conversion from 'const T*' to 'T*'

Group

LANGUAGE

Scope

Function

Syntax
  -Ec
  
  
Arguments

None

Default

None

Description

Enabling this non-ANSI compliant extension allows the compiler to treat a pointer to a constant type like a pointer to the non-constant equivalent of the type. Earlier Compilers did not check a store to a constant object through a pointer. This option is useful when compiling older source code.

Listing: Converting `const T*' to `T*'


void f() {
  int *i;

  const int *j;

  i=j; /* C++ illegal, but with -Ec ok! */

}

struct A {

  int i;

};

void g() {

  const struct A *a;

  a->i=3; /* ANSI C/C++ illegal, but with -Ec ok! */

}

void h() {

  const int *i;

  *i=23; /* ANSI-C/C++ illegal, but with -Ec ok! */

}
Defines

None

Pragmas

None

Listing: Example


-Ec
void myfun(const int *p){

  *p = 0; // some Compilers do not issue an error