Return string to Python



  • On 01/11/2013 at 11:44, xxxxxxxx wrote:

    Could you please add the /EHsc compiler option to your project settings and retry?



  • On 01/11/2013 at 12:21, xxxxxxxx wrote:

    I change it using:

    1. Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
    2. Click the C/C++ folder.
    3. Click the Code Generation property page.
    4. Modify the Enable C++ Exceptions property.

    Should I also add some code and if so what code?
    MS gives as an example:
    See also http://msdn.microsoft.com/en-us/library/1deeycx5(v=vs.90).aspx

        
            // compiler_options_EHA.cpp
        // compile with: /EHa
        #include <iostream>
        #include <excpt.h>
        using namespace std;
        
        void fail() {   // generates SE and attempts to catch it using catch(...)
           try {
              int i = 0, j = 1;
              j /= i;   // This will throw a SE (divide by zero).
              printf("%d", j); 
           }
           catch(...) {   // catch block will only be executed under /EHa
              cout<<"Caught an exception in catch(...)."<<endl;
           }
        }
        
        int main() {
           __try {
              fail(); 
           }
        
           // __except will only catch an exception here
           __except(EXCEPTION_EXECUTE_HANDLER) {   
           // if the exception was not caught by the catch(...) inside fail()
              cout << "An exception was caught in __except." << endl;
           }
        }
    


  • On 01/11/2013 at 12:23, xxxxxxxx wrote:

    The warning is gone, but the error is still there.

    1>d:\program files\maxon\cinema 4d r14\plugins\cinema4dsdk\niklas 5.cpp(162) : warning C4267: 'argument' : conversion from 'size_t' to 'LONG', possible loss of data
    1>     Creating library D:\Program Files\MAXON\CINEMA 4D R14\plugins\cinema4dsdk\obj\GetLicense\x64_Release\GetLicense.cdl64.lib and object D:\Program Files\MAXON\CINEMA 4D R14\plugins\cinema4dsdk\obj\GetLicense\x64_Release\GetLicense.cdl64.exp
    1>  cinema4dsdk.vcxproj -> D:\Program Files\MAXON\CINEMA 4D R14\plugins\cinema4dsdk\GetLicense.cdl64
    ========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
    


  • On 01/11/2013 at 12:35, xxxxxxxx wrote:

    Great, the warning was supposed to drop. :) Does it still crash?



  • On 01/11/2013 at 12:44, xxxxxxxx wrote:

    Yes, sorry. The error is still there.
    Also, it does not crash.
    The call to python is working, I do get a return value and the code is executed ok.
    Except when i close down cinema 4d, I get the error message.
    Not while working?



  • On 01/11/2013 at 14:50, xxxxxxxx wrote:

    There is NO error when comp and link in 32 bit debug mode.
    32 release mode give an error.

    I cannot debug in 64 bit because the linker cannot find 'kernel32.lib'?

    1>------ Build started: Project: GetLicense, Configuration: Debug x64 ------
    1>  niklas 5.cpp
    1>d:\program files\maxon\cinema 4d r14\plugins\cinema4dsdk\niklas 5.cpp(160) : warning C4267: 'argument' : conversion from 'size_t' to 'LONG', possible loss of data
    1>LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
    ========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
    

    And again, all seems to be functioning correctly.
    Only when I exit cinema, the error pops up?

    Also when debugging I see a lot of:
    "Cannot find or open the PDB file"



  • On 06/11/2013 at 08:39, xxxxxxxx wrote:

    Thanks for sending me the code. I'm currently examining it. What I can say is that the error comes
    not from my original code, but from your use of the standard library. Though I can't tell you at the
    moment why and how to fix it.

    Maxon does not officially support using the standard library, yet you require it. I've successfully
    made use of the standard library myself in plugins, so I am interested in where the issue is.

    Best,
    -Niklas



  • On 08/11/2013 at 10:38, xxxxxxxx wrote:

    Ok, thanks for the support.
    I hope you can solve it quickly.
    We want to bring out a new plugin this month, but we still have to decide how to protect.
    Using easily crack-able python, or a bit more difficult C++ library.

    Did you ever called C++ from python using the standard library?

    Regards, Pim



  • On 10/11/2013 at 05:25, xxxxxxxx wrote:

    Hi Pim,

    if you don't need the Cinema 4D Api, it is really no problem to create a DLL which makes use of the
    C++ standard library. The problem is that the Cinema 4D Api and the use of the std library are
    conflicting sometimes. Unfortunately I don't have a solution to your problem yet (which uses the
    Cinema 4D Api).

    In case you do not need the C4D Api, you can create a new VC++ project from scratch (without
    the cinema4sdk as the original project).

    Best,
    -Niklas



  • On 10/11/2013 at 08:55, xxxxxxxx wrote:

    Hi Niklas,

    Correct, I now created a C++ function with no C4D in it at all and just call it.
    No problem there.

    So like you say " The problem is that the Cinema 4D Api and the use of the std library are
    conflicting sometimes".
    However, it would be nice to mix C4D and standard C++ in one routine and call it from Python.
    If you fix it one day, please let me know.
    I continue on the above road (not mixing C4D and standard C++).
    Thanks for the support.

    Pim


Log in to reply