Adding a header in another generates multiple errors

Hello, I downloaded a small program that I was able to compile successfully.

Then I started to modify it, through the adding of some header files of a project of my own that I know to work and started to add some of my files to it.

I found a file called sph.hh that is were I want to make the changes and started to add several header files from my own project. Each time I added one, I tried to compile the program. And every time I was successfully until I added the last header.

Then I had an explosion of errors. I think it's too much to post here, it would
pollute the screen. Instead I will do a fairly large resume of the kind of errors that I started to get, in the hope that someone can point me to some direction to try to understand what happened. Any code piece that someone finds necessary to see, ask that I will put here. I can put I file with all the error messages and the full source if someone asks (and if there is an option for this in the forum I can't see any)

main.cpp:29:7: error: expected nested-name-specifier before ‘namespace’
(happens with namespace std and another user defined one)

main.cpp:29:7: error: expected unqualified-id before ‘namespace’
main.cpp:29:7: error: expected ‘;’ before ‘namespace’
(this unqualified-id shows twice)

main.cpp:47:1: error: ‘ofVtkWriter’ does not name a type
error: ‘std::numeric_limits<double>::infinity’ is not a type


main.cpp:419:1: error: expected ‘}’ at end of input
(last line of main)

sph.hh:317:38: error: cannot call member function ‘float RayTracer::rand01()’ without object
p += jitter*spacing*rand01()*randomDirection();
(rand01 is not a function of Raytracer with is one of my classes)


main.cpp:78:1: error: too many initializers for ‘RayTracer::<anonymous struct> [0]’
In file included from /media/windows/Demos/sph/main.cpp:25:0:
(same as above RayTracer doesn't have anything to do with anonymous struct)

There are countless messages like this where a member function of the program code being considered as belonging to my code.

At least you should post the line where the error occurs (and perhaps the previous line too)
You can upload the whole project to github

> main.cpp:29:7: error: expected ‘;’ before ‘namespace’
the previous line should have ended in ';'
If it is an #include, then you may forgot to close the class definition

> main.cpp:47:1: error: ‘ofVtkWriter’ does not name a type
> error: ‘std::numeric_limits<double>::infinity’ is not a type
¿missing include?

> main.cpp:419:1: error: expected ‘}’ at end of input
missmatched braces

> rand01 is not a function of Raytracer with is one of my classes
if the compiler is seeing it as such, perhaps you forgot to close the class definition };
Thanks for the suggestions. It was the lack of a bracket to close a class that was causing all the errors.
Topic archived. No new replies allowed.