question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

does it work with wchar_t?

See original GitHub issue

I am getting an error with wchar_t. I also included #include <stddef.h> to bypass clang error but I do get following

PANIC: [Panic] String cannot be of zero length. (Parameter 'oldValue')
   at System.String.Replace(String oldValue, String newValue)
   at C2CS.UseCases.AbstractSyntaxTreeC.ClangTranslationUnitExplorer.Location(CXCursor cursor, Nullable`1 type)
   at C2CS.UseCases.AbstractSyntaxTreeC.ClangTranslationUnitExplorer.VisitTranslationUnit(CXTranslationUnit translationUnit)
   at C2CS.UseCases.AbstractSyntaxTreeC.ClangTranslationUnitExplorer.AbstractSyntaxTree(CXTranslationUnit translationUnit, Int32 bitness)
   at C2CS.UseCases.AbstractSyntaxTreeC.UseCase.Explore(CXTranslationUnit translationUnit, ImmutableArray`1 includeDirectories, ImmutableArray`1 ignoredFiles, ImmutableArray`1 opaqueTypes, ImmutableArray`1 whitelistFunctionNames, Int32 bitness)
   at C2CS.UseCases.AbstractSyntaxTreeC.UseCase.Execute(Request request, Response response)
   at C2CS.UseCase`2.Execute(TRequest request)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:20 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
lithiumtoastcommented, Oct 5, 2021

Consider the case where a C library uses C strings (char*) for identifiers that are most likely less than 25 characters in length. E.g. “PlayerEntity”, “WeaponComponent”, “RenderingSystem”, etc. These strings are used frequently and usually out of context to the global C functions as part of the API to do something significant such as getting an entity or updating a component, etc, and then returning a callback. I do not want the garbage collector in C# to allocate memory in heap 0 for these strings from the callback. Instead I rather run a quick hash over the C string and use a hashtable to know if that C string’s contents has already has an analogous memory allocated in the GC and use that reference instead.

System.String.Intern(string str) would work if it accepted a raw pointer to a C style string. Otherwise, it accepts a string as input but that string instance still has to be allocated first which is not great. Also, according to the docs the memory would be retained until the application exits or restarts which is not great either.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is handling unicode character with wchar_t good? Does it ...
Usually, for historical reasons, we pick char for single-byte encodings (e.g. ASCII) and UTF-8, and wchar_t for UTF-16 (particularly on Windows ...
Read more >
Working with Strings - Win32 apps
In this article ... Windows natively supports Unicode strings for UI elements, file names, and so forth. Unicode is the preferred character ...
Read more >
Video: Create a chart
Create a chart (graph) that is recommended for your data, almost as fast as using the chart wizard that is no longer available....
Read more >
How to work with UTF-8 or wchar_t characters?
Am trying to display messages with non-english charcters, but for some reason non-english characters does not seem to work as expected.
Read more >
Still no wchar support? · Issue #1199 · gabime/spdlog
It works now after I define it in my client code. IMHO, this could turn down Windows users from the get-go. The info...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found