Compilation error "Foam::xyz has not been declared"
Hi all,
I guess this is a simple questions to all of you knowing c++ programming, but I don't get it right now: I have a file test.C including a function call Quote:
When compiling, I get the error message Quote:
What do I have to include at which position, so that the function call finds my function? Arne |
Hello Arne,
did you #inlcude "xyz.H" into your main file? Did you compile the xyz.C? Best Kathrin |
Hi Kathrin,
thanks for the hint with compiling xyz.C. This itself originally compiled before, but due to some changes, it maybe could not be found now. Including xyz.C in my test.C now solved it. But is including a .C file via #include a good idea? Normally, I only do this with header files. Alternatively, how do I compile the single xyz.C file before? wmake xyz.C gives Quote:
|
Greetings to all!
@Arne: have you ever done the following exercise? http://openfoamwiki.net/index.php/Ho...ure_to_icoFoam I'll give you a hint :) "Make/files": Quote:
Bruno |
Thanks Bruno,
I know this exercise ;). For me it's not straight forward due to the fact that I have two C-files test.C and xyz.C, whereas test.C holds the main() function and xyz.C only some methods which have to be called from within test.C For "compile the single xyz.C file before" I meant something like g++ xyz.C with additional arguments (as this does not know the Foam files). Nevertheless, #include xyz.C works so far. Arne |
Arne,
do you have a Make folder in your directory? The just edit the "file" file and add Code:
xyz.C Run wmake. Just try! |
To build upon Bruno's answer, the usual way to write the makefile is:
Code:
xyz.C |
Now I got it.
Thank you Anton for making this point for me. There's no .H file. I was so much into the nomal class structure, so I totally misunderstood. I never wanted to include some .C file. Maybe it would be a good idea to program that way that it will match the normal OpenFOAM structure but its not necessary. You may find the fowmNew scripts quite helpfull. There's a link in the wiki. I just cannot remember. Best Kathrin |
Thanks to all, now I got it as well ;).
Arne |
Hi,
I think I have a similar problem as reported by Arne. I have solver (its structure is similar to pisoFoam) and I would like to add an overloaded function (lets call the function simple). The function looks like Code:
volScalarField simple(volScalarField& unfiltered) What I did so far: I have a file simplefilter.C with the code above and a file simplefilter.H which contains Code:
volScalarField simple(volScalarField& unfiltered); Hope it is not confusing so far?! :) Now, this is already pretty messed up and running wmake gives me the expected error: volScalarField, volVectorField and volTensorField do not name a type. Well, I don't include the corresponding headers like fvCFD.H etc. in simplefilter.C which probably cause the error... My question, is there a more simple (also elegant) way to add an overloaded function as the one mentioned above to a solver? Any hints are much appreciated! Best, Florian |
Greetings Florian,
OK, when in doubt: isolate and conquer! Step one: put your new functions in the same file as the main .C file and put them before the main function, but after the includes. This way you know the definitions are available on-site. Step two: replace said functions with a single include of a header that has those functions. Seems pointless, but it's a helpful mnemonic. Step three:
The premise for this last step: fvCFD.H is included before newStuff.H, therefore the necessary definitions are ready to be used when the compiler seems the newStuff.H file. Best regards, Bruno |
All times are GMT -4. The time now is 15:59. |