- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the Windows Compiler documentation, it is stated that this ISO C++ feature is supported , atleast if we use flags forGnu and ISO standard. In Linux*, its allowed starting from 11.1 compiler, whereas its an error in Windows*.
When will this feature be implemented in Windows*. And what other GNU extension features are present that are supported in Linux* , but are not supported in Windows*. Please provide the list if its documented.
When porting code fromgcc to Windows* , the customers are facing lot of problems, as it may need lot of modification.
What all GNU features will be implemented in Intel Compiler for Windows in future releases.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[bash]#include#include int concat_fopen (char *s1, char *s2, char *mode) { char str[strlen (s1) + strlen (s2) + 1]; strcpy (str, s1); strcat (str, s2); return 1; } [/bash]
In Windows, it gives error.
While in Linux 11.1 compiler, it works (w/o any flag).
While, using gcc -pedantic provides a suitable warning:--
warning: ISO C++ forbids variable-size array `str'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> error in Windows*.
Can you please point to the documentation? Variable length arrays is *NOT* an ISO C++ feature. It is a C99 feature, and is supported under the /Qstd=c99 option (when you compile a C program).
> When will this feature be implemented in Windows*. And what other GNU extension features are present > that are supported in Linux* , but are not supported in Windows*. Please provide the list if its documented.
Our goal is to becompatible with Microsoft on Windows. There are no gnu compatibility flags and no plans to support any Gnu specificextensions on Windows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, its listed as a C99 feature in the compiler documentation. I thought it to be included in ISO C++, though the doc lists that specifically as c99 . And variable-length arrays is in the list.
However, the code that I posted was tried with /Qstd=c99 flag, and the following error is emitted:--
C:\Documents and Settings\mkulka3\My Documents\Intel-Docs\KBstuff\462642>icl /Qs
td=c99 vararr.cpp
Intel C++ Compiler for applications running on IA-32, Version 11.1 Build 2
0090421 Package ID: composer.061
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
vararr.cpp
vararr.cpp(7): error: function call is not allowed in a constant expression
char str[strlen (s1) + strlen (s2) + 1];
^
vararr.cpp(7): error: expression must have a constant value
char str[strlen (s1) + strlen (s2) + 1];
^
vararr.cpp(7): error: function call is not allowed in a constant expression
char str[strlen (s1) + strlen (s2) + 1];
^
vararr.cpp(7): error: expression must have a constant value
char str[strlen (s1) + strlen (s2) + 1];
///////////////////////////////////
It works well under Linux, so I suppose this should be escalated for Windows. Please let me know .
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
char* str = (char*)_alloca(strlen (s1) + strlen (s2) + 1);
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, its listed as a C99 feature in the compiler documentation. I thought it to be included in ISO C++, though the doc lists that specifically as c99 . And variable-length arrays is in the list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But, if Windows* compiler need to be compatible with Microsoft*, then the code posted by me not working could be fine, since the cl compiler also does report the same. But I do not know the /Qstd=c99 equivalent of icl for the cl .
Is there any option for this which we can apply for cl compiler
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
char* str = (char*)_alloca(10); // buffer of 10 chars
can be accessed as str[0] through str[9] as intended
and accessed str[-n] and str[9+m] as unintended
_alloca allocates off of stack at run time.
gnu permits runtime array size allocation off stack whereas Windows "standard" does not.
I do not know why /Qstd=c99 did not enable this functionality
There are other quirks with gnu such as structure declaration with initialization using ".member=value" with no structure name. Unfortunately this requires use of #if #else #endif or use of clever macros.
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks I got it now.
Statement like char arr
So in Windows*, we have to use _alloca , or malloc (dynamic on heap) , though the array indices can be flexible
That helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
char str[MAXPATH];
But then use the str... functions than enforce buffer overflow testing.
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page