c++ - DMC on large source files
- Michael (8/8) Oct 10 2007 When trying to compile large (approx. 2.2mb) source file I'm getting
- chris elliott (3/13) Oct 10 2007 did you set -HP in your dmc command line?
- Michael (2/4) Oct 10 2007 Yes I tried values from 50 to 1000, same error though.
- Walter Bright (5/15) Oct 10 2007 This can happen also if you have an unterminated string, and the
- Michael (17/17) Oct 10 2007 This happens because of huge switch statement.
- Walter Bright (15/34) Oct 11 2007 Try splitting the case statement into two:
- DQNOK (19/22) Oct 16 2007 What does the compiler do with case statements? I was told as a
- Walter Bright (3/6) Oct 16 2007 Compilers use different strategies depending on the number and density
- Heinz Saathoff (6/12) Oct 16 2007 But only if the source is one long line. Otherwise the compiler will
When trying to compile large (approx. 2.2mb) source file I'm getting following error: nbytes = 65600, ph_maxsize = 65520 Internal error: ph 1848 --- errorlevel 1 In c++ beta forum one said its due to macro expansion buffer overflow. Is there any way to tell dmc to use larger buffer or any other way around this problem?
Oct 10 2007
did you set -HP in your dmc command line? http://www.digitalmars.com/ctg/sc.html#dashCapHCapP Michael wrote:When trying to compile large (approx. 2.2mb) source file I'm getting following error: nbytes = 65600, ph_maxsize = 65520 Internal error: ph 1848 --- errorlevel 1 In c++ beta forum one said its due to macro expansion buffer overflow. Is there any way to tell dmc to use larger buffer or any other way around this problem?
Oct 10 2007
== Quote from chris elliott (biol75 york.ac.uk)'s articledid you set -HP in your dmc command line? http://www.digitalmars.com/ctg/sc.html#dashCapHCapPYes I tried values from 50 to 1000, same error though.
Oct 10 2007
Michael wrote:When trying to compile large (approx. 2.2mb) source file I'm getting following error: nbytes = 65600, ph_maxsize = 65520 Internal error: ph 1848 --- errorlevel 1 In c++ beta forum one said its due to macro expansion buffer overflow. Is there any way to tell dmc to use larger buffer or any other way around this problem?This can happen also if you have an unterminated string, and the compiler tries to read in your whole source file into one string. I'd try the 'divide-and-conquer' approach. Divide the source file in half, and see which side generates the error. Rinse, repeat.
Oct 10 2007
This happens because of huge switch statement. Huge means number of 'case' statements over 4050. Smallest test case can be produced using following ruby script: === cut === print "int main() {\n" print "\tint i = 0;\n" print "\tswitch(i) {\n" 1.upto(ARGV[0].to_i) do |x| end print "\t}\n" print "dummy:\n" print "\treturn 0;\n" print "}" === cut === Everything else in that huge file compiles fine. Anything can be done about it?
Oct 10 2007
Michael wrote:This happens because of huge switch statement. Huge means number of 'case' statements over 4050. Smallest test case can be produced using following ruby script: === cut === print "int main() {\n" print "\tint i = 0;\n" print "\tswitch(i) {\n" 1.upto(ARGV[0].to_i) do |x| end print "\t}\n" print "dummy:\n" print "\treturn 0;\n" print "}" === cut === Everything else in that huge file compiles fine. Anything can be done about it?Try splitting the case statement into two: switch (i) { case 1: case 2: ... default: switch (i) { case 1000: case 1001: ... } }
Oct 11 2007
== Quote from Walter Bright (newshound1 digitalmars.com)'s articleMichael wrote:What does the compiler do with case statements? I was told as a youth to use them instead of if elseif elseif ... else constructs because they were more efficient. Then I disassembled one (of my old) compiler's output and saw that it just tested each case sequentially; just like the if else construct. On that (single) basis, I've usually veered toward using arrays of functions instead of case statements. Instead of switch( i ) { case 0: do0thing; case 1: do1thing; case 2: do2thing; } I write: do_n_thing[i](); Is it customary nowadays in good compilers to transform switch statements into a set of internal jmps, or do they check thru every case sequentially? How should one deal with 4000 cases? DavidThis happens because of huge switch statement. Huge means number of 'case' statements over 4050.
Oct 16 2007
DQNOK wrote:Is it customary nowadays in good compilers to transform switch statements into a set of internal jmps, or do they check thru every case sequentially? How should one deal with 4000 cases?Compilers use different strategies depending on the number and density of the cases.
Oct 16 2007
Hello, Walter Bright wrote...But only if the source is one long line. Otherwise the compiler will give the error Lexical error: unterminated string - HeinzIn c++ beta forum one said its due to macro expansion buffer overflow. Is there any way to tell dmc to use larger buffer or any other way around this problem?This can happen also if you have an unterminated string, and the compiler tries to read in your whole source file into one string.
Oct 16 2007