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

Group

LANGUAGE

Scope

Function

Syntax
-Ec

Arguments

None

Default

None

Description

If this non-ANSI compliant extension is enabled, a pointer to a constant type is treated 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 if some older source has to be compiled.

Defines

None

Pragmas

None

Examples

See the following listings for examples using -Ec conversions.

Listing: Conversion from 'const T*' to 'T*


void f() {
  int *i;

  const int *j;

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

}

struct A {

  int i;

};

void g() {

  const struct A *a;

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

}

void h() {

  const int *i;

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

}
Listing: Assigning a value to a "constant" pointer


-Ec
void foo(const int *p){

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