71
The concept / Re: Tutor_14 (C++ VS2022 GDImage64 tutorial)
« Last post by Shao Voon Wong on August 26, 2023, 09:02:41 am »Hi Patrice,
I cannot build in debug x64 x86 build and release x86 build of your Tutor 14. There are some errors and many errors due to the invalid WCHAR* conversion. If I try out to write some GDImage code, I am not going to start from scratch; I am going to take your existing Tutor 14 code and remove the code which I do not need to write a zooming photo viewer application. I must be able to debug using the debug build when something goes wrong. Right now, I am unable to build a debug build.
In 1990s, using Turbo C. I was able to write something like
Starting from the early 2000s, I was not allowed to do this. A const keyword must be used.
For example, given the MyFunction below
If MyFunction modifies "Good Holidays" which is a static memory area, then the next time, MyFunction is called again, the text won't be "Good Holidays". This is why const must be used for string literals. I never verify if this is true because it is an industry practice that every C/C++ developer and I has to follow.
Assigning char* to const char* is allowed.
but the opposite is not allowed by the compiler.
Can you modify all the in parameters of WCHAR* to const WCHAR* in GDImage? This is to cut down the compile errors I have to fix when compiling in debug build. The side effort of this modification is you cannot modify const WCHAR* argument inside your function.
What do you think?
I cannot build in debug x64 x86 build and release x86 build of your Tutor 14. There are some errors and many errors due to the invalid WCHAR* conversion. If I try out to write some GDImage code, I am not going to start from scratch; I am going to take your existing Tutor 14 code and remove the code which I do not need to write a zooming photo viewer application. I must be able to debug using the debug build when something goes wrong. Right now, I am unable to build a debug build.
In 1990s, using Turbo C. I was able to write something like
Code: [Select]
char* text = "Good Holidays";
Starting from the early 2000s, I was not allowed to do this. A const keyword must be used.
Code: [Select]
const char* text = "Good Holidays";
For example, given the MyFunction below
Code: [Select]
void MyFunction()
{
char* text = "Good Holidays";
// code that modifies the content which text is pointing to.
}
If MyFunction modifies "Good Holidays" which is a static memory area, then the next time, MyFunction is called again, the text won't be "Good Holidays". This is why const must be used for string literals. I never verify if this is true because it is an industry practice that every C/C++ developer and I has to follow.
Assigning char* to const char* is allowed.
Code: [Select]
char* text = ???
const char* text2 = text; // allowed
but the opposite is not allowed by the compiler.
Code: [Select]
const char* text = ???
char* text2 = text; // error: not allowed.
Can you modify all the in parameters of WCHAR* to const WCHAR* in GDImage? This is to cut down the compile errors I have to fix when compiling in debug build. The side effort of this modification is you cannot modify const WCHAR* argument inside your function.
What do you think?