Author Topic: How can i use a static L"string" as a parameter in a C function?  (Read 145 times)

JohnClaw

  • Newbie
  • *
  • Posts: 23
    • View Profile
I have some problems with this subject. For example, i has Test.dll, Test.lib and Test.h. So when i try to call C function declared in Test.h: TestFunction(L"info") BCX translates it's code to C like this: TestFunction(L "info"). So BCX adds a space after L and it makes compilation to fail. How can i fix that? Help me, please.
« Last Edit: June 04, 2024, 09:17:03 AM by JohnClaw »

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2039
    • View Profile
Re: How can i use a static L"string" as a parameter in a C function?
« Reply #1 on: June 04, 2024, 10:12:33 AM »
You have several options.  Here are two common ones:

1) use the built-in BCX ANSITOWIDE function:

 TestFunction (ANSITOWIDE("info"))

2)  Treat it as a C statement by using the BCX exclamation point operator.

! TestFunction(L"info");


JohnClaw

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: How can i use a static L"string" as a parameter in a C function?
« Reply #2 on: June 05, 2024, 05:26:18 AM »
Thank you very much, MrBcx. Now my code compiles without errors.