Welcome, Guest. Please login or register.

Author Topic: G++ problems  (Read 3953 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline bytecode

  • Newbie
  • *
  • Join Date: Nov 2003
  • Posts: 3
    • Show all replies
Re: G++ problems
« on: November 26, 2003, 03:28:27 PM »
Just so that you know, standard C++ headers don't have any .h extension. Those are deprecated, pre-standard headers. There is no guarantee that they'll behave the same way on different implementations, or that they'll be present at all.

So, include , , , etc, and not , , , etc.

The same holds true for C headers. There is no guarantee that a complete C89 environment will be present. So include , , etc, and not , , etc.

Everything inside the aforementioned headers should be in the std namespace. So you can use something like:

std::cout << "hello world!" << std::endl;

or

using namespace std;
cout << "hello world!" << endl;

or

using std::cout;
using std::endl;
cout << "hello world!" << endl;

or even:

namespace s = std;
s::cout << "hello world!" << s::endl;


Remember that even C functions should now be in the std namespace (it's sadly not always implemented that way), so if you want to use say, printf, use std::printf (or one of the options above).


Hope this helps.
 

Offline bytecode

  • Newbie
  • *
  • Join Date: Nov 2003
  • Posts: 3
    • Show all replies
Re: G++ problems
« Reply #1 on: November 27, 2003, 02:05:21 AM »
Quote
@bytecode
In the C++ tutorial book I'm using, it mentions that about the .h, and it compiles fine under G++ in windoze. But the Amiga version I have doesn't seem to have those versions, unless I'm looking at this the completely wrong way (it complains it cannot find them without the .h extension)


I'm wondering... Have you tried to search for say, "iostream" or "iostream.h"? You might have to set up some environment variable that points to the directory holding the headers.

I remember using gcc on UAE, and prior to building anything, I would run a *nix shell (sh). Try this, maybe?

WORK> sh
> g++ -o hellocpp hello.cpp
> ./hellocpp

It's quite possible that the shell will set the correct variables for you (on *nix I'd tell you to look in $HOME/.bashrc or /etc/bashrc, or even /etc/profile, but I have no idea where this shell emulation might have written it, if at all). Note that *nix is case sensitive, and so will that shell emulator.

If that doesn't work, I'll try and install GCC on UAE again.


Quote

BTW Welcome to A.org


This is actually my 4th or 5th post, but I've been so active that my account disappeared :-D. Thanks though  :-).


Hope this helps.