0

Lets assume there are three files f1.hpp, f2.hpp, f3.hpp. Now say f2 has f1 included in it and f3 have f1 and f2 included in it.Making a py file that contents of f1, f2, and f3 defined now this is causing a 'struct' type redefinition or 'class' type redefinition warning and then crashes with use of undefined type 'type'

Eg: f1.hpp

#include <iostream>
namespace nam {
    //some types struct and class
}

f2.hpp

#include <f1.hpp>

namespace nam {
    //some types struct and class 
    //with f1 type or class as an argument
}

f3.hpp

#include <f1.hpp>
#include <f2.hpp>
namespace nam {
    //some types struct and class 
    //with f1 and f2 type or class as an argument
}

error message:

ex1.hpp(26): error C2011: 'namspace::classcpp': 'class' type 
redefinition
ex1.hpp(26): note: see declaration of 'namspace::classcpp'
pycpp.cpp(1489): error C2027: use of undefined type 
'namspace::classcpp'
ex1.hpp(26): note: see declaration of 'namspace::classcpp'

Now assume i have more the 3 file with this with their own random but necessary includes. How do define them in cython?

  • 1
    Please don't post pictures of text – DavidW Dec 26 '22 at 16:36
  • I've voted to close as missing an [mre] (so none of us can hope to know what you've done). But you are using include guards, right? – DavidW Dec 26 '22 at 16:39
  • Ive edited the content so that you would get some idea of what my actual code looks like – Akshayakeerthi Duraisamy Dec 27 '22 at 02:42
  • 1
    This has nothing to do with Cython it seems. You just need [include guards](https://stackoverflow.com/q/8020113/364696) or `#pragma once` in your headers so being multiply-included is safe... Should have been one of the first things you learned after basic syntax when it comes to developing C/C++ headers. – ShadowRanger Dec 27 '22 at 02:43

0 Answers0