Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

[FEATURE REQUEST] C99 stuff in C++

Andy_B_
Beginner
281 Views

Hi,

The question is simple. I do not know yet what the HELL (yes!) you did not think about it, since MinGW does it already, as well as Clang and a few others.

Could you please permit the use of designated initializers in C++, just like in C99 ?

Like... struct point p = { .y = yvalue, .x = xvalue };

Some will ask me the reason to it? Why not using a contructor will say the most annoying people...

That's not the question. Using a contructor is the same as using for example

struct point p = { yvalue, xvalue }

p = Point(yvalue, xvalue)

In either case,

  • you don't see the name of the field you set in the declaration
  • you must pass all parameters, even the one that are not revelant for a particular use and should be initialized to zero, so no automatic initialization : you have to specify values for ALL the fields/members/whatever
  • in a struct containing like 200 fields, if in a particular case you only need to use like 20 fields, and others can be zero, YOU WANT designated initializers, it just becomes a must, enough to actually mix C code with C++ just to be sure it'll work, by compiling a separate file in C called for example "data.c".

Trust me, it would be valuable, even though its non standard. And hell, if it bothers you that much to be non standard, why not putting it in a parameter?

Like -permit-c99-initializers

Do something Intel! I think Linux ICC already has it, I'm asking to add it for Windows.

Thanks!

EDIT: Oh... I forgot... It's more a hope than an official feature request, but still. Why not adding -Qstd=gnu++98 in Windows? I mean... really... some gcc extensions are really helpful sometimes.

0 Kudos
3 Replies
Judith_W_Intel
Employee
281 Views

 

Regarding the last question (support for /Qstd=gnu++98 on Windows) have you tried this option?

/Qgcc-dialect:<version>
          enable a limited gcc-compatible dialect on Windows. The gcc
          version may be specified as 440, 450 or 460.
            Example: /Qgcc-dialect:440 -> gcc 4.4 compatibility
 

Unfortunately there's no guarantee that the Windows system headers will work as expected with this option.

0 Kudos
TimP
Honored Contributor III
281 Views

Judith Ward (Intel) wrote:

 

/Qgcc-dialect:<version>
          enable a limited gcc-compatible dialect on Windows. The gcc
          version may be specified as 440, 450 or 460.
            Example: /Qgcc-dialect:440 -> gcc 4.4 compatibility
 

Unfortunately there's no guarantee that the Windows system headers will work as expected with this option.

I suppose you'd be wanting g++ 4.8 compatibility.  Compatibility with mingw isn't a priority for ICL, as the latter relies on Visual Studio headers.  Much of the c++11 stuff requires Visual Studio 2013, I think including the limited bits of C99 which Microsoft supports.  As I just got a new license for VS2012 and can't justify the expense, I'd stick with g++ myself if I wanted this on Windows.  In fact, I'm making an update build of g++ for win7 right now on this old box.

0 Kudos
JenniferJ
Moderator
281 Views

the option JudyW provided does work.

C:\temp>type c99.cpp
typedef struct {
  int x, y;
} point;

void foo() {
         point p = { .y = 10, .x = 20 };
}
C:\temp>icl /c /Qgcc-dialect:440 c99.cpp
Intel(R) C++ Compiler XE for applications running on IA-32, Version 14.0.1.139 Build 20131008
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

c99.cpp

C:\temp>

0 Kudos
Reply