System::out Access violation

Help
wqf
2005-08-09
2013-03-22
  • wqf
    wqf
    2005-08-09

    My code is :
    System::out->println("test");

    It will throw "Access violation",
    I found System::out is null.
    why?

    my environment: vc6 sp4, acdk 4.14

     
    • Hi,

      ACDK code needs to be initialized and wrapped by
      a main function.

      Here is the sample code:

      #include <acdk.h>
      #include <acdk/lang/System.h>

      using namespace acdk::lang;

      int acdkmain(RStringArray args)
      {
        // Your code starts here and System::out is
        // initialized
        System::out->println("Hello from miniacdksample");
        return 0;
      }

      int
      main(int argc, char* argv[], char** envptr) // C++ Main
      {
        // ACDK (f.e. System::out) is uninitialized
        return acdk::lang::System::main(acdkmain, argc, argv, envptr); // Initialize ACDK
      }

      Because ACDK has to manage several issues -
      like threading, memory management, locals and exception handling
      (which translates "Access violation" in the '->' operator
      to a NullPointerException) - the C++ main function
      has to be wrapped with an acdk main function.

      Regards,
      Roger