- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Template instantiation
Operating System - HP-UX
1748181
Members
3661
Online
108759
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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-10-2009 09:15 PM
тАО02-10-2009 09:15 PM
Template instantiation
Hi,
I am trying to compile STLPort 4.5.3 using aCC 3.55. HP-UX PA-RISC 2.0 11.11
It contains a code snippet which can be summarized as follows:
template
void GetMax(myType A){
int a[A];
cout<<"Done";
};
int main()
{
cout <<"Ashu";
GetMax(10);
cout <<"Kanu";
return 0;
}
so whenever I compile it using my compiler i receive the following error messages:
Error 176: "template.c", line 8 # Size of array must be an integral constant expression
of value greater than 0.
int a[A];
^
Error 445: "template.c", line 16 # Cannot recover from earlier errors.
GetMax(10);
How do I get rid of this message, so that I would be able to compile the STLPort?
Thanks
-Deo
I am trying to compile STLPort 4.5.3 using aCC 3.55. HP-UX PA-RISC 2.0 11.11
It contains a code snippet which can be summarized as follows:
template
void GetMax(myType A){
int a[A];
cout<<"Done";
};
int main()
{
cout <<"Ashu";
GetMax
cout <<"Kanu";
return 0;
}
so whenever I compile it using my compiler i receive the following error messages:
Error 176: "template.c", line 8 # Size of array must be an integral constant expression
of value greater than 0.
int a[A];
^
Error 445: "template.c", line 16 # Cannot recover from earlier errors.
GetMax
How do I get rid of this message, so that I would be able to compile the STLPort?
Thanks
-Deo
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-10-2009 11:38 PM
тАО02-10-2009 11:38 PM
Re: Template instantiation
Please consider the following program:
# include
# define _STLP_DATA_ALIGNMENT 10
# define _Pthread_alloc_obj int
# define _STLP_mutex int
template
struct _Pthread_alloc_per_thread_state {
typedef _Pthread_alloc_obj __obj;
enum { _S_NFREELISTS = _Max_size/_STLP_DATA_ALIGNMENT };
_Pthread_alloc_obj* volatile __free_list[_S_NFREELISTS];
// Free list link for list of available per thread structures.
// When one of these becomes available for reuse due to thread
// termination, any objects in its free list remain associated
// with it. The whole struct thread.
_STLP_mutex _M_lock;
};
main()
{
/*iNT tp=5000;
size_t sz= sizeof(tp);
struct _Pthread_alloc_per_thread_state deo;
*/
printf ("Deo");
}
This compiles using CC on Solaris machine, however I am not able to compile the same on my HP machine
Thanks
-Deo
# include
# define _STLP_DATA_ALIGNMENT 10
# define _Pthread_alloc_obj int
# define _STLP_mutex int
template
struct _Pthread_alloc_per_thread_state {
typedef _Pthread_alloc_obj __obj;
enum { _S_NFREELISTS = _Max_size/_STLP_DATA_ALIGNMENT };
_Pthread_alloc_obj* volatile __free_list[_S_NFREELISTS];
// Free list link for list of available per thread structures.
// When one of these becomes available for reuse due to thread
// termination, any objects in its free list remain associated
// with it. The whole struct thread.
_STLP_mutex _M_lock;
};
main()
{
/*iNT tp=5000;
size_t sz= sizeof(tp);
struct _Pthread_alloc_per_thread_state
*/
printf ("Deo");
}
This compiles using CC on Solaris machine, however I am not able to compile the same on my HP machine
Thanks
-Deo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-11-2009 03:15 AM
тАО02-11-2009 03:15 AM
Re: Template instantiation
template
void GetMax(T A){ int a[A]; }
GetMax(10);
This is a dynamic array. If you want the size to be a constant, you need to do something like your next case with a non-type template parm.
>size_t sz = sizeof(tp);
>struct _Pthread_alloc_per_thread_state deo;
(It is silly to use scummy C struct/class in C++, drop the "struct".)
>This compiles using CC on Solaris machine
It's not Standard. You'll need to use:
const size_t sz = sizeof(tp);
_Pthread_alloc_per_thread_state deo;
>main()
This must be "int main".
void GetMax(T A){ int a[A]; }
GetMax
This is a dynamic array. If you want the size to be a constant, you need to do something like your next case with a non-type template parm.
>size_t sz = sizeof(tp);
>struct _Pthread_alloc_per_thread_state
(It is silly to use scummy C struct/class in C++, drop the "struct".)
>This compiles using CC on Solaris machine
It's not Standard. You'll need to use:
const size_t sz = sizeof(tp);
_Pthread_alloc_per_thread_state
>main()
This must be "int main".
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP