On Mo, Sep 02, 2013, Chris Sorenson wrote:
Greets all,
Another sequence of bads that cropped up using the Silicon Graphics MIPSpro compiler, any thoughts? To wit:
cc-1028 CC: ERROR File = hyphenator.cc, Line = 147 The expression used must have a constant value.
char chars [l + 1]; ^ [more similar cases]
It seems that your compiler does not support arrays with variable length, which are standard since C99, as far as I see. It could be fixed by replacing this line (as an example) by:
char *chars = new char [l + 1];
and later
delete[] chars;
However, I'd like to check other possibilities. A short search lead me to <http://www.sgi.com/products/software/irix/tools/c.html>, according to which newer versions support C99. Which version do you use?
I'm using MIPSpro 7.4.3 (the most current version is 7.4.4) but in C99 mode it can't compile C++ code. Not to worry I'll #ifdef my way around the variable length arrays, I guess I didn't look closely enough to realize that was what those were, thanks!
On Mo, Sep 02, 2013, Chris Sorenson wrote:
On Mo, Sep 02, 2013, Chris Sorenson wrote:
Greets all,
Another sequence of bads that cropped up using the Silicon Graphics MIPSpro compiler, any thoughts? To wit:
cc-1028 CC: ERROR File = hyphenator.cc, Line = 147 The expression used must have a constant value.
char chars [l + 1]; ^ [more similar cases]
It seems that your compiler does not support arrays with variable length, which are standard since C99, as far as I see. It could be fixed by replacing this line (as an example) by:
char *chars = new char [l + 1];
and later
delete[] chars;
However, I'd like to check other possibilities. A short search lead me to <http://www.sgi.com/products/software/irix/tools/c.html>, according to which newer versions support C99. Which version do you use?
I'm using MIPSpro 7.4.3 (the most current version is 7.4.4) but in C99 mode it can't compile C++ code. Not to worry I'll #ifdef my way around the variable length arrays, I guess I didn't look closely enough to realize that was what those were, thanks!
Thinking about it again, variable length arrays are a feature of C, but not of C++, although it seems that most C++ compilers support it. Since this is a nice feature, but standard C++ should be supported, I've thought of testing it by the configure script, and then hide two different implementations behind a macro. See attached patch, which should be applied to the current hg repository. What do you think? Cris: If you run ./autogen.sh && ./configure, you should see a line: checking for support of variable length arrays in C++... no Is this correct? Sebastian
[...]
Thinking about it again, variable length arrays are a feature of C, but not of C++, although it seems that most C++ compilers support it. Since this is a nice feature, but standard C++ should be supported, I've thought of testing it by the configure script, and then hide two different implementations behind a macro. See attached patch, which should be applied to the current hg repository.
What do you think? [...]
Third round: I agree with Jorge that this is quite too complex; and profiling shows no performance gain of using the heap over using the stack, so I've replaced it by new and delete. Cris: please test the latest version from hg, it should compile now. I've tried to force g++ to raise an error in this case, by using this example: --- #include <stdlib.h> int main() { int n = rand() % 10 + 1; char c[n]; } --- but both "g++ -std=c++98 test.cc" and "g++ -std=c++11 test.cc" do not complain. Does someone have an idea? ("g++ --version" => "g++ (Debian 4.7.2-5) 4.7.2") Sebastian
On Fri, Sep 06, 2013 at 11:46:10AM +0200, Sebastian Geerken wrote:
[...]
Thinking about it again, variable length arrays are a feature of C, but not of C++, although it seems that most C++ compilers support it. Since this is a nice feature, but standard C++ should be supported, I've thought of testing it by the configure script, and then hide two different implementations behind a macro. See attached patch, which should be applied to the current hg repository.
What do you think? [...]
Third round: I agree with Jorge that this is quite too complex; and profiling shows no performance gain of using the heap over using the stack, so I've replaced it by new and delete. Cris: please test the latest version from hg, it should compile now.
There's a memory problem with the sizeof(buf) because it returns the pointer size, not the array length! Please see the attached test case for details. (Compile with: g++ -W -Wall size3.cc -o size3) -- Cheers Jorge.-
On Fr, Sep 06, 2013, Jorge Arellano Cid wrote:
On Fri, Sep 06, 2013 at 11:46:10AM +0200, Sebastian Geerken wrote:
[...]
Thinking about it again, variable length arrays are a feature of C, but not of C++, although it seems that most C++ compilers support it. Since this is a nice feature, but standard C++ should be supported, I've thought of testing it by the configure script, and then hide two different implementations behind a macro. See attached patch, which should be applied to the current hg repository.
What do you think? [...]
Third round: I agree with Jorge that this is quite too complex; and profiling shows no performance gain of using the heap over using the stack, so I've replaced it by new and delete. Cris: please test the latest version from hg, it should compile now.
There's a memory problem with the sizeof(buf) because it returns the pointer size, not the array length!
Please see the attached test case for details.
(Compile with: g++ -W -Wall size3.cc -o size3)
That's why paths are limited to 7 characters. :-) Loading hyphenation patterns for language 'de' from '/usr/lo' and exceptions from '/usr/lo' ... Anyway, fixed now. Sebastian
participants (3)
-
csoren@isd.net
-
jcid@dillo.org
-
sgeerken@dillo.org