You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2008/02/14 01:03:45 UTC
svn commit: r627616 - in /stdcxx/trunk/etc/config/src:
EXTERN_FUNCTION_TEMPLATE.cpp extern_function_template_imp.cpp
extern_function_template_imp.h
Author: faridz
Date: Wed Feb 13 16:03:41 2008
New Revision: 627616
URL: http://svn.apache.org/viewvc?rev=627616&view=rev
Log:
2008-02-14 Farid Zaripov <fa...@epam.com>
* etc/config/src/extern_function_template_imp.h: New header file to
check the extern function templates.
* etc/config/src/extern_function_template_imp.cpp: Removed definitions
of struct S<> and foobar<>(), #included extern_function_template_imp.h.
* etc/config/src/EXTERN_FUNCTION_TEMPLATE.cpp: Ditto.
Added:
stdcxx/trunk/etc/config/src/extern_function_template_imp.h (with props)
Modified:
stdcxx/trunk/etc/config/src/EXTERN_FUNCTION_TEMPLATE.cpp
stdcxx/trunk/etc/config/src/extern_function_template_imp.cpp
Modified: stdcxx/trunk/etc/config/src/EXTERN_FUNCTION_TEMPLATE.cpp
URL: http://svn.apache.org/viewvc/stdcxx/trunk/etc/config/src/EXTERN_FUNCTION_TEMPLATE.cpp?rev=627616&r1=627615&r2=627616&view=diff
==============================================================================
--- stdcxx/trunk/etc/config/src/EXTERN_FUNCTION_TEMPLATE.cpp (original)
+++ stdcxx/trunk/etc/config/src/EXTERN_FUNCTION_TEMPLATE.cpp Wed Feb 13 16:03:41 2008
@@ -22,39 +22,23 @@
*
**************************************************************************/
-// establish a dependency on extern_function_template_imp.{cpp,o}
+// include a file containing the definition of a template
+// and an extern template directive referencing an explicit
+// instantiation of the same template in extern_function_template_imp.o
+
+#include "extern_function_template_imp.h"
+
+// establish a dependency on extern_function_template_imp.o to make sure
+// the extern_function_template_imp.cpp is compiled before this file
#ifndef _RWSTD_NO_extern_function_template_imp
-// link the object file produced by compiling this file
-// with the object file below
+// link with the object file below
// LDOPTS = extern_function_template_imp.o
#endif // _RWSTD_NO_extern_function_template_imp
-
-template <class T>
-struct S
-{
- T t;
-};
-
-
-template <class T>
-S<T> foobar (S<T> s)
-{
- // foobar<int>() explicitly instantiated in extern_function_template_imp.cpp
- // is defined to set s.t to 1
- s.t = -1;
-
- return s;
-}
-
-extern template S<int> foobar (S<int>);
-
int main ()
{
- // S<int>::bar () is defined to return 1 in extern_function_template_imp.o
-
S<int> s;
int res = 0;
Modified: stdcxx/trunk/etc/config/src/extern_function_template_imp.cpp
URL: http://svn.apache.org/viewvc/stdcxx/trunk/etc/config/src/extern_function_template_imp.cpp?rev=627616&r1=627615&r2=627616&view=diff
==============================================================================
--- stdcxx/trunk/etc/config/src/extern_function_template_imp.cpp (original)
+++ stdcxx/trunk/etc/config/src/extern_function_template_imp.cpp Wed Feb 13 16:03:41 2008
@@ -21,21 +21,6 @@
*
**************************************************************************/
-template <class T>
-struct S
-{
- T t;
-};
-
-template <class T>
-S<T> foobar (S<T> s)
-{
- s.t = 1;
-
- return s;
-}
-
-template S<int> foobar (S<int>);
-
-// extern template S<int> foobar(S<int>) declared
-// in EXTERN_FUNCTION_TEMPLATE.cpp returns -1
+// explicitly instantiate the template defined in the header
+#define INSTANTIATE
+#include "extern_function_template_imp.h"
Added: stdcxx/trunk/etc/config/src/extern_function_template_imp.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/etc/config/src/extern_function_template_imp.h?rev=627616&view=auto
==============================================================================
--- stdcxx/trunk/etc/config/src/extern_function_template_imp.h (added)
+++ stdcxx/trunk/etc/config/src/extern_function_template_imp.h Wed Feb 13 16:03:41 2008
@@ -0,0 +1,63 @@
+
+/***************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the License); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 1999-2007 Rogue Wave Software, Inc.
+ *
+ **************************************************************************/
+
+// avoid including <config.h> here to avoid inadvertently
+// trying to introduce dependencies on other config tests
+// that the config infrastructure won't know about (since
+// it only searches .cpp files for them)
+// #include <config.h>
+
+#if __GNUG__ >= 3
+ // disable gcc 3.x (and beyond) error: ISO C++ forbids the use
+ // of `extern' on explicit instantiations
+# pragma GCC system_header
+#endif // gcc >= 3
+
+
+template <class T>
+struct S
+{
+ T t;
+};
+
+template <class T>
+S<T> foobar (S<T> s)
+{
+#if defined (INSTANTIATE)
+ s.t = 1;
+#else // if !defined (INSTANTIATE)
+ s.t = -1;
+#endif // INSTANTIATE
+
+ return s;
+}
+
+#if defined (INSTANTIATE)
+
+template S<int> foobar (S<int>);
+
+#else // if !defined (INSTANTIATE)
+
+extern template S<int> foobar (S<int>);
+
+#endif // INSTANTIATE
Propchange: stdcxx/trunk/etc/config/src/extern_function_template_imp.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: stdcxx/trunk/etc/config/src/extern_function_template_imp.h
------------------------------------------------------------------------------
svn:keywords = Id