Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7895925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:45:41+00:00 2026-06-03T07:45:41+00:00

I am using the boost library for getting the current system time and my

  • 0

I am using the boost library for getting the current system time and my code works but visualt studio 2010 exits after the program.the debugger breaks while trying to free the non existing pointer. I know this is because of the boost native code.Since there is no error if I comment the boost portion of code.

Till now I tried using the #pragma as explained in MSDN but with no success.Can someone provide me some suggestions.? (I also tried GetSystemTime function to get the time but i cannot get the microsecond detail like boost.)

MY Code

#pragma managed(push, off)
void GetSystemDateTime(SDateTime& stimeblock);
#pragma managed(pop)

int main()
{

c++/cli code

SDateTime stimestruct[1];
//call to the function having the boost code..
GetSystemDateTime(stimestruct[0]);

}

Function Definition

 #pragma managed(push, off)
  void GetSystemDateTime(SDateTime& timeblock)
    {

   // SYSTEMTIME time;
   // GetSystemTime(&time);
   // WORD millis = (time.wSecond * 1000) + time.wMilliseconds;

    boost::posix_time::ptime now  = boost::posix_time::microsec_clock::local_time();
    std::tm pt_tm = to_tm(now);
    std::cout <<  now << std::endl;
    //std::cout <<  time.wYear<< time.wMonth<<time.wDay //<<time.wHour<<time.wMinute<<time.wSecond<<time.wMilliseconds << std::endl;
    std::string timestring =  to_iso_string(now);
    std::string sYear  = timestring.substr (0,4);
    std::string sMonth = timestring.substr (4,2);
    std::string sDay   = timestring.substr (6,2);
    std::string sHour  = timestring.substr (9,2);
    std::string sMinute = timestring.substr (11,2);
    std::string sSecond = timestring.substr (13,2);
    std::string sUSecond = timestring.substr (16);

    istringstream isYear(sYear);
    istringstream isMonth(sMonth);
    istringstream isDay(sDay);
    istringstream isHour(sHour);
    istringstream isMinute(sMinute);
    istringstream isSec(sSecond);
    istringstream isUSec(sUSecond);
    // use is like an input stream
    int iYear,iMonth,iDay,iHour,iMinute,iSecond,iUSecond;
    isYear >> iYear;
    isMonth >>iMonth;
    isDay >>iDay;
    isHour >>iHour;
    isMinute >>iMinute;
    isSec >>iSecond;
    isUSec >>iUSecond;


    timeblock.uiYear = iYear;
    timeblock.usiMonth = time.wMonth;
    timeblock.usiDay = time.wDay;
    timeblock.usiHour = time.wHour;
    timeblock.usiMinute = time.wMinute;
    timeblock.usiSec = time.wSecond;

    timeblock.udiUSec = time.wMilliseconds;

    // Display version information

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:45:42+00:00Added an answer on June 3, 2026 at 7:45 am

    I’ve seen this error caused by using a static variable in native code in a C++/CLI assembly.

    The only workaround I found was to remove the static variable, e.g., by moving it to class or file scope.

    However, if this static variable is in the boost code, doing so may not be easy/possible. In that case, you could create a separate C++ file that’s compiled without /clr, use the boost function in that file, and link that into your C++/CLI assembly.

    This error seems to be caused by the compiler generating incorrect code. I filed a bug with Microsoft, which was closed “won’t fix”, but the compiler team gave some other workarounds in their response.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have started using the boost unit testing library for a large existing code
I am using the timed_wait from boost C++ library and I am getting a
I'm getting debugger errors when using the boost serilazation library. To fix these I
I'm writing a game in c++ using boost.python library as script system. I have
I wrote a c++ program using boost library in Xcode. Here is my code.
I am writing a Graph-class using boost-graph-library. I use custom vertex and edge properties
What is the purpose of using the Boost.MPI library? Does it increase performance? And
What are the differences in using boost:thread, Posix Thread library and the new C++11
I'm using boost::asio, and I have code like this: void CServer::Start(int port) { tcp::acceptor
Right now I'm generating a random enumerator using boost's random library. Basically I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.