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

  • Home
  • SEARCH
  • 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 9105645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:09:19+00:00 2026-06-17T02:09:19+00:00

I am using C++ Builder XE3 and I have met a weird problem with

  • 0

I am using C++ Builder XE3 and I have met a weird problem with AnsiString.

Just look at below code

//Code 1: first time
AnsiString temp1 = "test" ;
funcA(temp1,temp1);

//Code 2: second time    
String uTemp2 = "test";
AnsiString temp2 = uTemp2;
funcA(temp2,temp2);

Out of my imagine, it works well in the first time, however it throws a “Bad Format” Exception in the second time. And even I just called funcA once with Code 2 the problem remained.

Since it makes no difference when I ShowMessage within temp1 or temp2. I totally can not understand why the two times of call gave me different results.

funcA is from a 3rd library with a little bit complicated code. So before I trace the code of this library I think I should know what the difference is with Code1 and Code2.

Thanks.

  • 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-17T02:09:20+00:00Added an answer on June 17, 2026 at 2:09 am

    As far as funcA() is concerned, there is absolutely no difference whether a char* or a UnicodeString was assigned to the AnsiString. The in-memory representation of the AnsiString data is the same in both cases. So there has to be an issue inside of funcA() itself that is causing the error, regardless of how you prepare the AnsiString. But without knowing what funcA() actually does and what input it expects, there is no way to diagnose this problem. you will have to trace the logic inside of funcA().

    You say funcA() comes from a third-party library. What kind of library is it exactly? Is it a statically linked LIB, or an external DLL/BPL? It makes a big difference. If it is an external DLL/BPL, then you cannot safely pass non-POD data, such as AnsiString, over the DLL boundary unless the DLL/BPL has been compiled with the EXACT SAME compiler, RTL, and Memory Manager as your EXE (in the case of a BPL, that also means enabling Runtime Packages in both BPL and EXE projects). If that is not the case, then it is likely that the DLL/BPL is using a different RTL/MM that interprets the in-memory AnsiString data differently than your EXE does. The in-memory data of an AnsiString was changed in CB2009 to include new fields (namely a codepage and an element size), so if the DLL/BPL was compiled in an earlier compiler version, bad things can happen when it tries to use an AnsiString from your newer compiler (and vice versa).

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

Sidebar

Related Questions

I am using C++ Builder XE3. Currently I have such macro as below: #define
I have a problem with statically linking dll files into project. I'm using Builder
Using Flex Builder 3 : I have been getting this problem in every single
Friends i'm using string builder for generating Passenger List in which i have used
I need to create the below xml using builder, how would I do it?
Using report builder 3.0, I have a report that queries a cube. How do
I'm using Flash Builder 4.7. When starting a new Actionscript Project, the first popup
I have been using Flash Builder to build my flex software and I am
Using Flex Builder : I have created a new Actionscript Project. I want to
Using C++ Builder under Rad Studio XE I have created a simple Datasnap server

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.