-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: experimenting with Qt - how to cast away const for argv #592
Comments
Btw. this is the generated cpp file:
|
Thanks, good question! (Edited to add:) Removing the It's good to have the default be But the standard does allow the strings to be mutable, so we want to support that valid use case and provide a way to get at the mutable How does that sound? |
@hsutter Thank you. Yes it solves the issue. But maybe another idea could be worthy to consider. I noticed that Pro: This would keep things simple to learn and explain to users. There would be no need for additional |
The real default-const value is in the safe `args` themselves, and `argc` and `argv` should be their standard selves for compatibility. See #592 comment thread, thanks @vladimir-kraus !
I think you've convinced me, that the real default-const value is in the safe |
Thank you. I think this design now draws clear and easy-to-communicate dividing line between the "old" style and the "new" style. Btw. the new style, which is basically an array of strings, is similar to what programmers may know from Java or C#. |
See discussion in hsutter#592 comment thread
The real default-const value is in the safe `args` themselves, and `argc` and `argv` should be their standard selves for compatibility. See hsutter#592 comment thread, thanks @vladimir-kraus !
I am experimenting with combination of Qt, one of the most widely used C++ frameworks, and cppfront. I was curious how hard this could be. And I believe it can give cppfront some hard battle testing because Qt is very opinionated framework which is doing lots of thinks "a bit differently". In order to test it, I created this code to make the simplest possible QtWidgets application.
It builds with cppfront and then with MSVC well and runs without any problems. But it fails to build with clang. It gives error
error: static_assert failed due to requirement 'program_violates_type_safety_guarantee<char **, const char *const *>' "No safe 'as' cast available - please check your cast"
.The cast is there because the required signature is
QApplication(int&, char**)
whileargs.argv
ischar const* const*
. I triedstatic_cast
but cppfront compiler told me it is not allowed. I believe there is a good memory-safety reason why this is not possible.Is there any vanilla cppfront way of solving this issue and allowing instantiate
QApplication
object? Something that is simple and memory safe at the same?And also - isn't the fact that it builds well with MSVC a problem? It seems that this constitutes a memory safety issue. IWould this be possible to catch and handle (compile erorr?) at cppfront level?
The text was updated successfully, but these errors were encountered: