Professional Web Applications Themes

using stl header - Mac Programming

all, try to compile a C++ program using STL features. g++ could not resolve the "#include <string>", noticed that the header is in "/usr/include/gcc/darwin/3.1/g++-v3", could compile with explicit path, but just wondering what to setup to include with explicitly setting the path. thanks, ym...

  1. #1

    Default using stl header

    all,

    try to compile a C++ program using STL features. g++ could not resolve the
    "#include <string>", noticed that the header is in
    "/usr/include/gcc/darwin/3.1/g++-v3", could compile with explicit path,
    but just wondering what to setup to include with explicitly setting the
    path.

    thanks,

    ym
    Yuming Guest

  2. #2

    Default Re: using stl header

    Hi ym,

    Yuming Ma <com> writes: 

    Works fine here. What is your command line and your error message?

    benny
    Benjamin Guest

  3. #3

    Default Re: using stl header

    ben,

    thanks for your replying. thte command line is:
    g++ -gstabs str.C

    str.C:
    1: #include <stream.h>
    2: #include <string>
    3: int main()
    4: {
    5: string a("hello");
    6: cout << a << endl;
    7: }

    error mesg:
    str.C: In function `int main()':
    str.C:5: `string' undeclared (first use this function)
    str.C:5: (Each undeclared identifier is reported only once for each
    function it
    appears in.)
    str.C:5: p error before `(' token
    str.C:6: `a' undeclared (first use this function)


    thank,

    yuming,

    On Tue, 9 Dec 2003, Benjamin Riefenstahl wrote:
     
    >
    > Works fine here. What is your command line and your error message?
    >
    > benny
    >[/ref]
    Yuming Guest

  4. #4

    Default Re: using stl header

    i missed the scope modifier

    using std::string;

    thanks ben,


    On Tue, 9 Dec 2003, Yuming Ma wrote:
     
    > >
    > > Works fine here. What is your command line and your error message?
    > >
    > > benny
    > >[/ref]
    >[/ref]
    Yuming Guest

  5. #5

    Default Re: using stl header

    In article <local>,
    Yuming Ma <com> wrote:
     

    Maybe the file needs a .cpp extension?
    Sean Guest

  6. #6

    Default Re: using stl header

    In article <aei.ca>,
    Sean McBride <org> wrote:
     
    >
    > Maybe the file needs a .cpp extension?[/ref]

    Nah; the code needs to use 'std::string' instead of 'string'.

    -Eric

    --
    Eric Albert edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

Similar Threads

  1. Dumb Mail::Header question: getting the header
    By Bernie in forum PERL Modules
    Replies: 2
    Last Post: December 4th, 09:35 PM
  2. Header Help
    By DaRemedy in forum PHP Development
    Replies: 12
    Last Post: October 14th, 12:02 AM
  3. Image in header column (not replacing column header text)
    By hansiman in forum ASP.NET Data Grid Control
    Replies: 3
    Last Post: February 7th, 12:17 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139