public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC compile problem ...
@ 2002-09-27  9:09 gcc
  2002-09-27  9:30 ` Sebastian Huber
  2002-09-27  9:35 ` John Love-Jensen
  0 siblings, 2 replies; 9+ messages in thread
From: gcc @ 2002-09-27  9:09 UTC (permalink / raw)
  To: gcc-help

Hello!

I have the following compile problem with gcc 3.0.4.

Borland C++ 5.5 and Microsoft Visual C++ 6.0 works well.

#include <string>
#include <iostream>

using namespace std;

class Test
{
public:
        string getString() { return "hallo"; }
};

int main(int argc, char* argv)
{
        Test test;

        string& s = test.getString(); // Error here
        // works well: string s = test.getString();
        cout << s << "\n";

        // gcc --version: 3.0.4
}

main.cpp: In function `int main (int, char *)':
main.cpp:17: initialization of non-const reference type `class string
&'
main.cpp:17: from rvalue of type `basic_string<char,
string_char_traits<char>, __default_alloc_template<true, 0> >'
make[1]: *** [main.o] Error 1

Why aren't there references allowed here with gcc? Is this not Ansi C++
conform?

Ciao,
Gerhard


^ permalink raw reply	[flat|nested] 9+ messages in thread
* gcc compile problem ...
@ 2000-01-26  6:51 Brian J. Dent
  2000-01-26 12:10 ` Alexandre Oliva
  2000-04-01  0:00 ` Brian J. Dent
  0 siblings, 2 replies; 9+ messages in thread
From: Brian J. Dent @ 2000-01-26  6:51 UTC (permalink / raw)
  To: help-gcc

gcc help,

Obviously I am new to the GNU gcc compiler.

I've been trying compile a program on our SUN with gcc 
(sparc-sun-solaris2.7/2.95.1) and it contains some intrinsic 
functions.  When I get to the point of linking it doesn't recognize the 
functions, eg:  sqrt.  Below is a test program.  What is missing that I am 
not finding the built-in functions to link with?  Thanks for any help.

file:marc.c:
#include <stdio.h>
#include <math.h>

main()
{
         double x = 2;
         printf("sqrt of %d is %f\n",x,sqrt(x));
}

gcc -c marc.c
gcc -o marc.out marc.o
Undefined                       first referenced
  symbol                             in file
sqrt                                marc.o
ld: fatal: Symbol referencing errors. No output written to marc.out
collect2: ld returned 1 exit status

- bjd
____________________________
Brian J. Dent
CompuDent
v (831) 649-0948 f (707) 222-1209
http://www.redshift.com/~briandent/

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-09-30 11:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-27  9:09 GCC compile problem gcc
2002-09-27  9:30 ` Sebastian Huber
2002-09-27  9:35 ` John Love-Jensen
2002-09-27 15:52   ` Sebastian Huber
2002-09-30  4:49     ` John Love-Jensen
  -- strict thread matches above, loose matches on Subject: below --
2000-01-26  6:51 gcc " Brian J. Dent
2000-01-26 12:10 ` Alexandre Oliva
2000-04-01  0:00   ` Alexandre Oliva
2000-04-01  0:00 ` Brian J. Dent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).