From f7de44c173da3ecb9ec3a6f4effef78644861d84 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Tue, 27 Nov 2001 04:30:22 +0000 Subject: [PATCH] added an entry for Comeau [SVN r11785] --- doc/problems_with_compilers.htm | 67 +++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/doc/problems_with_compilers.htm b/doc/problems_with_compilers.htm index 00d3ec9..df6473c 100644 --- a/doc/problems_with_compilers.htm +++ b/doc/problems_with_compilers.htm @@ -15,10 +15,12 @@

Contents


+

Metrowerks Codewarrior 7.0

-

Bad news - Metrowerks Codewarrior 7.0 has a bug in preprocessor (to be more +

Metrowerks Codewarrior 7.0 has a bug in preprocessor (to be more concrete, in function-like macro replacement mechanism) that restricts usage of the library to only very simple cases, at least if you don't write code that specifically address this issue; for example, the above NUMBERED_EXPRESSION @@ -36,8 +38,8 @@ int c IDENTITY_MACRO(IDENTITY_MACRO(COMMA_TOKEN))() d; // this doesn't expanded _inside_ of the nested IDENTITY_MACRO call - even although it's NOT followed by a '(' as the next preprocessing token - which is a clearly an incorrect behavior (see 16.3 [cpp.replace] para 9 for the detailed description of the - function-like macro replacement process). I haven't submitted bug report yet, - but I am going to.

+ function-like macro replacement process). I've submitted a bug report, but they + haven't confirmed it yet.

So, this is not a problem of the library, but probably something that needs to be mentioned in the documentation, may be with some examples of how to workaround the issue. Just to show one possible way around the problem, here is a NUMBERED_EXPRESSION @@ -53,6 +55,65 @@ int c IDENTITY_MACRO(IDENTITY_MACRO(COMMA_TOKEN))() d; // this doesn't /**/

Reported by Aleksey Gurtovoy

+ +

Comeau C/C++ 4.2.45.2 for Windows

+

It appears that their algorithm of macro call invocation is quite far + from ideal, because for the following code fragment (which is a part of + preprocessor_test.cpp), the + linear increasing of IS_FUNCTION_HELPER_TEST_MAX value leads to not even + quadratic, but something like exponential increasing of compilation time! + (see the timing data below). This behavior may or may not be problematic + for you, depending on how intense is your usage of the library. + +

+
#ifndef IS_FUNCTION_HELPER_TEST_MAX
+#define IS_FUNCTION_HELPER_TEST_MAX 40
+#endif
+
+typedef char yes_type;
+
+#define IS_FUNCTION_HELPER(I,A)\
+  template\
+  <BOOST_PREPROCESSOR_ENUM_PARAMS(BOOST_PREPROCESSOR_INC(I),class P)>\
+  yes_type is_function_helper(\
+    P0 (*)(BOOST_PREPROCESSOR_ENUM_SHIFTED_PARAMS(BOOST_PREPROCESSOR_INC(I),P)));
+
+BOOST_PREPROCESSOR_REPEAT_2ND(BOOST_PREPROCESSOR_INC(IS_FUNCTION_HELPER_TEST_MAX),IS_FUNCTION_HELPER,A)
+
+#undef IS_FUNCTION_HELPER
+
+ +

Timing data:

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
 Comeau C/C++ 4.2.45.2Microsoft Visual C++ 6.0 SP5
10 parameters< 1 sec< 1 sec
20 parameters~ 2 sec< 1 sec
30 parameters~ 15 sec< 1 sec
40 parameters~ 50 sec< 1 sec
+ +

Reported by Aleksey Gurtovoy

+

© Copyright Housemarque, Inc. 2001

Permission to copy, use, modify, sell and distribute this document is granted