Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
October 10, 2007 DMC on large source files | ||||
---|---|---|---|---|
| ||||
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? |
October 10, 2007 Re: DMC on large source files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michael | 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? |
October 10, 2007 Re: DMC on large source files | ||||
---|---|---|---|---|
| ||||
Posted in reply to chris elliott | == Quote from chris elliott (biol75@york.ac.uk)'s article
> did you set -HP in your dmc command line? http://www.digitalmars.com/ctg/sc.html#dashCapHCapP
Yes I tried values from 50 to 1000, same error though.
|
October 10, 2007 Re: DMC on large source files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michael | 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.
|
October 10, 2007 Re: DMC on large source files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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| print "\tcase #{x}: goto dummy;\n"; 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? |
October 11, 2007 Re: DMC on large source files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michael | 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|
> print "\tcase #{x}: goto dummy;\n";
> 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:
...
}
}
|
October 16, 2007 Re: DMC on large source files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Hello,
Walter Bright wrote...
> > 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.
But only if the source is one long line. Otherwise the compiler will
give the error
Lexical error: unterminated string
- Heinz
|
October 16, 2007 Re: DMC on large source files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | == Quote from Walter Bright (newshound1@digitalmars.com)'s article
> Michael wrote:
> > This happens because of huge switch statement.
> > Huge means number of 'case' statements over 4050.
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?
David
|
October 17, 2007 Re: DMC on large source files | ||||
---|---|---|---|---|
| ||||
Posted in reply to DQNOK | 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.
|
Copyright © 1999-2021 by the D Language Foundation