开发者

C++ compiler maximum number of classes

In meta-programming number of classes grows quite fast开发者_如何学C. Is maximum number of classes modern compiler allows, for example g++, something to be concerned about?

Thank you


I'd guess this question is best answered by the standard published by the C++ committee. But looking at this place, I can't see any upper limit on the number of classes although there is minimum quantity limit on many items (saying at least the given number of items of each type should be supported by the compiler but that is not a binding limit). If your compiler can support these minimum limits, you should be OK.

But what factors would have the say on the upper limits on the number of classes kindles my academic curiosity. I'd be glad to know if a compiler guru can answer that.


If you run on a 64-bit computer, you're unlikely to run out of any limitation in any modern compilers. Type information is likely to be dynamically allocated, rather than put into some hard-coded limited-size container.

I can think of some systems that might conceivably grow to be hard to compile in a 2 GB memory space as you'll have for a 32-bit computer. However, even though I've worked on some pretty big C++ code bases with lots of template metaprogramming, that hasn't actually been a problem in practice. The slowness of compilation and the annoyance of debugging probably will kill you before memory size does :-)


Given that the compiler's parse trees are just that—trees—I think it's safe to assume that compiler limits are a matter of overall complexity rather than the number of any one sort of entity.

Of course, someone with the source in front of them can give a more definite answer :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜