0
votes

I wanted to write a simple clang plug-in. So I just executed a "PrintFunctionNames" plug-in provided in llvm-clang. But when i tried to execute a command :

" clang -cc1 -load ../../Debug+Asserts/lib/libPrintFunctionNames.so -plugin print-fns some-input-file.c "

it gives me 1 fatal error :

fatal error: 'iostream.h' file not found
#include<iostream.h>
        ^
1 error generated.

I also tried using -I option providing a path for include directory of 'iostream' but it's still gives me the same error.

I tried it like:

'clang++ -I//usr/include/c++/4.6 -cc1 -load ../../../../Release+Asserts/lib/libPrintFunctionNames.so -plugin print-fns ak.cpp '

So how do I make this work?

4

4 Answers

2
votes

Don't add .h at the end.

#include <iostream>

That should fix it.

2
votes

iostream belongs to C++ not C. So you should include it as

#include <iostream>

Additionally since you are programming in C++ you should name your source file ending with .cpp not .c to make it clear to the compiler and everyone else, that you want to use C++. Also you might need to invoke clang++ in your first compiler call (but I am not sure about that in context of plugins)

1
votes

After the C++ language was standardized by the ISO, the header file named iostream.h was renamed to iostream. Change your program to use #include <iostream> instead and it should compile.

You will also need to add using namespace std; statement after each include (or prefix each reference to an iostream function/object with std::).

You can start by using this

#include <iostream>
using namespace std;

Once you are more comfortable with namespaces, you can remove the using statement & instead either use std::cout, std::cin etc or have a

using std::cout;
using std::cin;

etc.

0
votes

I meet the same question,

  • template.cpp
g++ template.cpp
compare<int>com1(3,7);
  1. List item
compare<double>com2(12.34,56.78); 
compare<char>com3('a','x'); 
cout<<",the max value:"<<com1.max()<<endl;   
cout<<",the max value:"<<com2.max()<<endl;
cout<<",the max value:"<<com3.max()<<endl;
return  0;

the question is up code segment composing not OK, use the shift + table typing next time.