Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Giving 20 errors when trying to add your library #5

Open
MaciejJezierski opened this issue Nov 10, 2018 · 6 comments
Open

Giving 20 errors when trying to add your library #5

MaciejJezierski opened this issue Nov 10, 2018 · 6 comments

Comments

@MaciejJezierski
Copy link

MaciejJezierski commented Nov 10, 2018

Like in subject.
./print.h:62:13: error: no template named 'basic_ostream'
typedef basic_ostream< char, char_traits > ostream;
^
./print.h:62:34: error: reference to 'char_traits' is ambiguous
typedef basic_ostream< char, char_traits > ostream;
^
./print.h:54:12: note: candidate found by name lookup is 'std::char_traits'
struct char_traits;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__string:75:29: note: candidate found by name lookup
is 'std::__1::char_traits'
struct _LIBCPP_TEMPLATE_VIS char_traits
^
In file included from Alg.cpp:4:
./print.h:62:50: error: expected '(' for function-style cast or type construction
typedef basic_ostream< char, char_traits > ostream;
~~~~^
./print.h:62:52: error: expected unqualified-id
typedef basic_ostream< char, char_traits > ostream;
^
./print.h:63:13: error: no template named 'basic_streambuf'; did you mean 'basic_stringbuf'?
typedef basic_streambuf< char, char_traits > streambuf;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/iosfwd:117:32: note: 'basic_stringbuf' declared here
class _LIBCPP_TEMPLATE_VIS basic_stringbuf;
^
In file included from Alg.cpp:4:
./print.h:63:36: error: reference to 'char_traits' is ambiguous
typedef basic_streambuf< char, char_traits > streambuf;
^
./print.h:54:12: note: candidate found by name lookup is 'std::char_traits'
struct char_traits;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__string:75:29: note: candidate found by name lookup
is 'std::__1::char_traits'
struct _LIBCPP_TEMPLATE_VIS char_traits
^
In file included from Alg.cpp:4:
./print.h:63:52: error: expected '(' for function-style cast or type construction
typedef basic_streambuf< char, char_traits > streambuf;
~~~~^
./print.h:63:54: error: expected unqualified-id
typedef basic_streambuf< char, char_traits > streambuf;
^
./print.h:81:13: error: use of undeclared identifier 'fputs_unlocked'; did you mean 'putc_unlocked'?
fputs_unlocked("\r", file); break;
^~~~~~~~~~~~~~
putc_unlocked
/usr/include/stdio.h:295:6: note: 'putc_unlocked' declared here
int putc_unlocked(int, FILE *);
^
In file included from Alg.cpp:4:
./print.h:81:28: error: cannot initialize a parameter of type 'int' with an lvalue of type 'const char [3]'
fputs_unlocked("\r", file); break;
^~~~~
/usr/include/stdio.h:295:23: note: passing argument to parameter here
int putc_unlocked(int, FILE *);
^
In file included from Alg.cpp:4:
./print.h:83:13: error: use of undeclared identifier 'fputs_unlocked'; did you mean 'putc_unlocked'?
fputs_unlocked("\n", file); break;
^~~~~~~~~~~~~~
putc_unlocked
/usr/include/stdio.h:295:6: note: 'putc_unlocked' declared here
int putc_unlocked(int, FILE *);
^
In file included from Alg.cpp:4:
./print.h:83:28: error: cannot initialize a parameter of type 'int' with an lvalue of type 'const char [3]'
fputs_unlocked("\n", file); break;
^~~~~
/usr/include/stdio.h:295:23: note: passing argument to parameter here
int putc_unlocked(int, FILE *);
^
In file included from Alg.cpp:4:
./print.h:85:13: error: use of undeclared identifier 'fputs_unlocked'; did you mean 'putc_unlocked'?
fputs_unlocked("\t", file); break;
^~~~~~~~~~~~~~
putc_unlocked
/usr/include/stdio.h:295:6: note: 'putc_unlocked' declared here
int putc_unlocked(int, FILE *);
^
In file included from Alg.cpp:4:
./print.h:85:28: error: cannot initialize a parameter of type 'int' with an lvalue of type 'const char [3]'
fputs_unlocked("\t", file); break;
^~~~~
/usr/include/stdio.h:295:23: note: passing argument to parameter here
int putc_unlocked(int, FILE *);
^
In file included from Alg.cpp:4:
./print.h:87:13: error: use of undeclared identifier 'fputs_unlocked'; did you mean 'putc_unlocked'?
fputs_unlocked("\\", file); break;
^~~~~~~~~~~~~~
putc_unlocked
/usr/include/stdio.h:295:6: note: 'putc_unlocked' declared here
int putc_unlocked(int, FILE *);
^
In file included from Alg.cpp:4:
./print.h:87:28: error: cannot initialize a parameter of type 'int' with an lvalue of type 'const char [3]'
fputs_unlocked("\\", file); break;
^~~~~~
/usr/include/stdio.h:295:23: note: passing argument to parameter here
int putc_unlocked(int, FILE *);
^
In file included from Alg.cpp:4:
./print.h:89:13: error: use of undeclared identifier 'fputs_unlocked'; did you mean 'putc_unlocked'?
fputs_unlocked("\"", file); break;
^~~~~~~~~~~~~~
putc_unlocked
/usr/include/stdio.h:295:6: note: 'putc_unlocked' declared here
int putc_unlocked(int, FILE *);
^
In file included from Alg.cpp:4:
./print.h:89:28: error: cannot initialize a parameter of type 'int' with an lvalue of type 'const char [3]'
fputs_unlocked("\"", file); break;
^~~~~~
/usr/include/stdio.h:295:23: note: passing argument to parameter here
int putc_unlocked(int, FILE *);
^
In file included from Alg.cpp:4:
./print.h:91:13: error: use of undeclared identifier 'fputs_unlocked'; did you mean 'putc_unlocked'?
fputs_unlocked("\0", file); break;
^~~~~~~~~~~~~~
putc_unlocked
/usr/include/stdio.h:295:6: note: 'putc_unlocked' declared here
int putc_unlocked(int, FILE *);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.

@adob
Copy link
Owner

adob commented Nov 11, 2018

How are you invoking gcc? Can you copy-and-paste the command line you used?

I would like to be able repro this on my machine otherwise it's very hard to fix.

@MaciejJezierski
Copy link
Author

As you didn't provide any command I should use and I am using visual studio code where I have specified build path to folder with source code and your print.h I am using just "g++ myprogram.cpp". (tried with gcc too, still same errors)

@adob
Copy link
Owner

adob commented Nov 11, 2018

If you have a source file that looks like this:

// basic_example.cpp
#include "print.h"

int main() {
    print "hello world";
}

you should be able to compile with g++ basic_example.cpp and it should work?

This doesn't work for you? This works for me on Linux but I don't have a Windows machine to try this on.

@MaciejJezierski
Copy link
Author

It shouldn't be problem but especially for you I wrote your example and I still get same errors. I am on MacOS but as it is unix based it shouldn't be problem too. Also I tried to compile it with all versions of g++.

@bigman1238
Copy link

i cant see my information ppl stole it

@nguyen116
Copy link

Gyyu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants