- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- CXX: Reference to instantiated template bug
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2010 10:39 AM
тАО02-01-2010 10:39 AM
CXX: Reference to instantiated template bug
COLOMA-ALAN>cxx/ver
HP C++ V7.3-009 for OpenVMS Alpha V8.3
COLOMA-ALAN>type a.h
#ifndef A_H
#define A_H
template
class Templ
{
public:
T* Func();
};
#endif
COLOMA-ALAN>type a.cpp
#include "a.h"
void someFunc()
{
int* ptr = Templ
}
COLOMA-ALAN>cxx a.cpp
void someFunc()
.....^
%CXX-E-REDEF, declaration has already been defined by function
"someFunc" (declared at line 3 of
"$1$DGA1269:[AEGANTONUK.temp]a.cpp;1")
at line number 3 in file $1$DGA1269:[AEGANTONUK.temp]a.cpp;1
%CXX-I-MESSAGE, 1 error detected in the compilation of "$1$DGA1269:[AEGANTONUK.temp]a.cpp;1".
====================
Interesting aspects of this bug:
COLOMA-ALAN>RENAME a.cpp b.cpp
COLOMA-ALAN>cxx b.cpp
---- No errors
Another interesting aspect of this bug:
COLOMA-ALAN>COPY a.cpp b.cpp
COLOMA-ALAN>cxx b.cpp
void someFunc()
.....^
%CXX-E-REDEF, declaration has already been defined by function
"someFunc" (declared at line 3 of
"$1$DGA1269:[AEGANTONUK.temp]b.cpp;1")
at line number 3 in file $1$DGA1269:[AEGANTONUK.temp]a.cpp;1
%CXX-I-MESSAGE, 1 error detected in the compilation of "$1$DGA1269:[AEGANTONUK.temp]b.cpp;1".
***** Why is the compiler trying to compile a.cpp?!?!?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2010 11:12 AM
тАО02-01-2010 11:12 AM
Re: CXX: Reference to instantiated template bug
either not using both "a.h" and "a.cpp" as
file names, or using /NOIMPLICIT_INCLUDE.
HELP CXX /IMPLICIT_INCLUDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2010 12:24 PM
тАО02-01-2010 12:24 PM
Re: CXX: Reference to instantiated template bug
Thanks!
That said: having this as a default without any kind diagnostic as to whats going on, while it may make for some backwards compatibility with something; is rather confusing for those who don't know about this compiler switch.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2010 12:30 PM
тАО02-01-2010 12:30 PM
Re: CXX: Reference to instantiated template bug
Knowing nothing, I assume that any serious
C++ user would prefer it this way. A visit
to the C++ language reference manual and/or
user guide might be informative.
Learning more (that is, anything useful)
about C++ has been on my to-do list for a
long time. Sadly, laziness is among my many
character flaws.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2010 01:06 PM
тАО02-01-2010 01:06 PM
Re: CXX: Reference to instantiated template bug
That said HP CXX is the only modern compiler that I've come across that has done this by default (I've used gcc, icc, and visual-c++).
These all require you to explicitly #include anything that the compiler sees.
Anyhow mystery solved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2010 06:32 PM
тАО02-04-2010 06:32 PM
Re: CXX: Reference to instantiated template bug
on v6.3-020 version of cxx, compiling a.cpp as above gives no errors, but when a.cpp is copied to b.cpp, your error appears:
void someFunc()
.....^
%CXX-E-REDEF, declaration has already been defined by function
"someFunc" (declared at line 3 of
/list produces:
_VMS_VER=70320022 __VMS_VERSION="V7.3-2 " __vms_version="V7.3-2 " __G_FLOAT
__D_FLOAT=0 __vms __VMS __INITIAL_POINTER_SIZE=0 __BIASED_FLT_ROUNDS=2
__32BITS __IEEE_FLOAT=0 __Alpha_AXP _LONGLONG __alpha__ __alpha __ALPHA
__DECCXX_VER=60390020 __MODEL_ARM __STD_ANSI __IMPLICIT_INCLUDE_ENABLED
__STDNEW __X_FLOAT __PRAGMA_ENVIRONMENT __DECCXX __EDG_VERSION__=243 __EDG__
__IMPLICIT_USING_STD __RTTI __EXCEPTIONS __GLOBAL_ARRAY_NEW
__BOOL_IS_A_RESERVED_WORD _BOOL_EXISTS __WCHAR_T _WCHAR_T __cplusplus
__TIME__="13:25:45" __DATE__="Feb 5 2010"
Amusing!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-05-2010 06:57 PM
тАО02-05-2010 06:57 PM
Re: CXX: Reference to instantiated template bug
Yes, this is from the very musty past.
>These all require you to explicitly #include anything that the compiler sees.
Right. On HP-UX we had the transition from cfront to aC++ but required an option.
>Steven: using /NOIMPLICIT_INCLUDE.
Yes I immediately thought of cfront.
>I assume that any serious C++ user would prefer it this way.
No, any serious C++ programmer knows the C++ Standard says that this cfront coding template coding style is obsolete and probably illegal.
If you want the template bodies, you explicitly include them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2010 03:38 PM
тАО02-09-2010 03:38 PM
Re: CXX: Reference to instantiated template bug
From what I can see in some configuration file, IBM AIX VisualAge C++ starting with version 5.0.2.0 also does implicit inclusion by default, but I cannot verify it.
I'm not sure about the Alpha compiler, but IPF compiler does not do implicit inclusion in gnu compatibility mode, so, if you are porting stuff from gcc, it may be a good idea to compile it with /stand=gnu.
-Boris
a.h
---
#ifndef A_H
#define A_H
template
class Templ
{
public:
T* Func();
};
#endif
a.cc
----
#include "a.h"
template
a.cpp
-----
#include "a.h"
int main() {
return *Templ
}
$ cxx a.cpp
$ cxxlink a.obj
$ cxx a.cpp/stand=gnu
$ cxxlink a.obj
%ILINK-W-NUDFSYMS, 1 undefined symbol:
%ILINK-I-UDFSYM, int *Templ
%ILINK-W-USEUNDEF, undefined symbol int *Templ
source code name: "Templ