gcc295 fail to compile C++ programs in FreeBSD 3.3

gcc295 fail to compile C++ programs in FreeBSD 3.3

Post by Rogelio J. Baucell » Wed, 29 Sep 1999 04:00:00



Hello everybody...

I am a long term C++ developer under Win32 and I have managed  to
successfully create and compile several C++ applications under RedHat Linux
6.0 using the GNU gcc-2.91.66.

I am starting to develop applications for the FreeBSD plataform but I have
faced the following problems:

1- I have developed a library whose header contain the following elements:
    * Standard C++ class definitions like:
        class A{
            ...
        };
    * Template functions and classes like:
        template <class _A> _A myfunc(...);
        template <class _B> class myclass{
            ...
        };

        I have installed gcc295 from the ports collection in FreeBSD
3.3-RELEASE which  includes the STL.

        whenever I compile the library using gcc295 I get the following
error:

gcc295 -DHAVE_CONFIG_H -I. -I. -I..     -D_GNU_SOURCE  -O2 -c WebPlusApp.cpp
In file included from WebPlusApp.cpp:7:
/usr/local/include/cgi-lib/cgi-lib_t.h:14: parse error before `>'

this is the actual code, line 14 is the one with template definition...

-----cgi-lib_t.h-------
namespace cgi{

//////////////////////////////////////////////////////////////////////
// Template functions and types
//////////////////////////////////////////////////////////////////////

template<class _Fn, class _A1, class _A2, class _A3, class _R> struct
MyStruct
{
        typedef _Fn first_argument_type;
.....

---------------------------------------------

The same source code will compile perfectly under RedHat Linux 6.0
(gcc-2.91.66) and Win32 (VC++6.0)

Is there any issue with gcc under FreeBSD I should be aware of?

Can anybody point me in the right direction where to look for information
about doing C++ under FreeBSD?

I have read the man pages, searched the gnu and FreeBSD web sites but can
not find anything related to it.

Any help will be greatly appreciated

Thanks

Rogelio J. Baucells
Advanced Total Systems, Inc.

 
 
 

gcc295 fail to compile C++ programs in FreeBSD 3.3

Post by FreeBSD use » Thu, 30 Sep 1999 04:00:00


Hi Rogilo,

Having *exactly* the same problem.
If you find any solution, patch, hint, whatever, please let me now.

I f somebody manages to successfully compile C++ programs under FreeBSB 3.2
or 3.3, please post.

Thanks



Quote:> Hello everybody...

> I am a long term C++ developer under Win32 and I have managed  to
> successfully create and compile several C++ applications under RedHat
Linux
> 6.0 using the GNU gcc-2.91.66.

> I am starting to develop applications for the FreeBSD plataform but I have
> faced the following problems:

> 1- I have developed a library whose header contain the following elements:
>     * Standard C++ class definitions like:
>         class A{
>             ...
>         };
>     * Template functions and classes like:
>         template <class _A> _A myfunc(...);
>         template <class _B> class myclass{
>             ...
>         };

>         I have installed gcc295 from the ports collection in FreeBSD
> 3.3-RELEASE which  includes the STL.

>         whenever I compile the library using gcc295 I get the following
> error:

> gcc295 -DHAVE_CONFIG_H -I. -I. -I..     -D_GNU_SOURCE  -O2 -c
WebPlusApp.cpp
> In file included from WebPlusApp.cpp:7:
> /usr/local/include/cgi-lib/cgi-lib_t.h:14: parse error before `>'

> this is the actual code, line 14 is the one with template definition...

> -----cgi-lib_t.h-------
> namespace cgi{

> //////////////////////////////////////////////////////////////////////
> // Template functions and types
> //////////////////////////////////////////////////////////////////////

> template<class _Fn, class _A1, class _A2, class _A3, class _R> struct
> MyStruct
> {
>         typedef _Fn first_argument_type;
> .....

> ---------------------------------------------

> The same source code will compile perfectly under RedHat Linux 6.0
> (gcc-2.91.66) and Win32 (VC++6.0)

> Is there any issue with gcc under FreeBSD I should be aware of?

> Can anybody point me in the right direction where to look for information
> about doing C++ under FreeBSD?

> I have read the man pages, searched the gnu and FreeBSD web sites but can
> not find anything related to it.

> Any help will be greatly appreciated

> Thanks

> Rogelio J. Baucells
> Advanced Total Systems, Inc.


 
 
 

gcc295 fail to compile C++ programs in FreeBSD 3.3

Post by German Tischle » Thu, 30 Sep 1999 04:00:00



Quote:>         I have installed gcc295 from the ports collection in FreeBSD
> 3.3-RELEASE which  includes the STL.
>         whenever I compile the library using gcc295 I get the following
> error:
> gcc295 -DHAVE_CONFIG_H -I. -I. -I..     -D_GNU_SOURCE  -O2 -c WebPlusApp.cpp
> In file included from WebPlusApp.cpp:7:
> /usr/local/include/cgi-lib/cgi-lib_t.h:14: parse error before `>'
> this is the actual code, line 14 is the one with template definition...

I think you are trying to compile C++ source with a C compiler.
The C++ compiler probably has a different name with ++ in it.

--


 
 
 

gcc295 fail to compile C++ programs in FreeBSD 3.3

Post by Gregory Bon » Thu, 30 Sep 1999 04:00:00



Quote:> template<class _Fn, class _A1, class _A2, class _A3, class _R> struct
> MyStruct
> {
>         typedef _Fn first_argument_type;
> .....

The FreeBSD <ctype.h> file #defines _R (which is a symbol in the
implementation name space and probably shouldn't be used as a name in
a user program...)
 
 
 

gcc295 fail to compile C++ programs in FreeBSD 3.3

Post by FreeBSD use » Fri, 01 Oct 1999 04:00:00


Thanks, that was excatly the problem. No only that, but I also was using
_A, _R and some othet _<one uppercase letter> in my code that was making the
compler crash.

I looked at the file ctype.h and found where the problem was. Linux ctype.h
is different (of course) and that's why it was crashing on FreeBSD but not
on Linux or win32. Thanks a lot.

Luis


> > template<class _Fn, class _A1, class _A2, class _A3, class _R> struct
> > MyStruct
> > {
> >         typedef _Fn first_argument_type;
> > .....

> The FreeBSD <ctype.h> file #defines _R (which is a symbol in the
> implementation name space and probably shouldn't be used as a name in
> a user program...)

 
 
 

gcc295 fail to compile C++ programs in FreeBSD 3.3

Post by FreeBSD use » Fri, 01 Oct 1999 04:00:00


You're absolutely right, Andy.

I forgot to set  Me.Bonehead=false before posting.

Regards,

Luis


> > _A, _R and some othet _<one uppercase letter> in my code that was making
the
> > compler crash.

> It wasn't crashing but simply reporting an error when you
> used ``invalid'' code.

 
 
 

gcc295 fail to compile C++ programs in FreeBSD 3.3

Post by Andy Newm » Sat, 02 Oct 1999 04:00:00



> _A, _R and some othet _<one uppercase letter> in my code that was making the
> compler crash.

It wasn't crashing but simply reporting an error when you
used ``invalid'' code.
 
 
 

1. trouble running/compiling freebsd 3.3-release

hi

i have a dual P100 box running freebsd-3.3-release with self-compiles
SMP kernel. but this machine behaves really strange. i can compile, but
sometimes, it fails on random files, that previously got compiled. no
changes done in source. and error message is just something else,
everytime... sometimes i get assembler errors due to unknown opcodes
(ex. "jna" but i think this is a right opcode) sometimes it yells about
unsigoed (note the typo, it's not in the source code)...
and further i have problems running OpenSSH it just computes wrong
checksums (it seems) and i can't connect...
i think of a dual-proccessor problem, but have no idea how to solve
this...

greetz Flavio and i hope somebody can help me...

--
to e-mail remove SPAM from email...

2. Programming terminal speaker

3. Compiling Pose 3.3 Under FreeBSD 4.2

4. 2.4.x: ide: smart ioctl() doesnt work...

5. KDE 1.1.2 won't compile under FreeBSD 3.3-STABLE

6. cwdcmd and less don't like eachother

7. GCC 2.8.1 compile failure on clean FreeBSD 3.3 install

8. LaserJet 5

9. Upgrading from FreeBSD 2.1 to FreeBSD 3.3 ?

10. FreeBSD 3.3 crashes while posting FreeBSD 4.0 crash details!!!

11. 3.3-R gdb problems with C++

12. C++ & NeXT 3.3