News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Code::Blocks, Scintilla and Fedora

Started by Folco, October 22, 2010, 06:03:16 PM

Previous topic - Next topic

Loaden

Quote from: jens on November 08, 2010, 12:21:17 PM
Can you test my new patch, works for me on XP SP3, wx2.8.10 and TDM gcc 4.5.0 (just for the core project-file at the moment).
Well done! testing passed.
And have a issue, I think we need change the lib name from "libwxscintilla.a" to "libcbscintilla.a" or "libwxscintilla_cb.a".
Because in wx2.9.x, the wxscintilla library named "libwxscintilla.a" too. :)

Loaden

#31
Quote from: jens on November 08, 2010, 04:34:13 PM
Quote from: Loaden on November 08, 2010, 03:37:55 PM
Quote from: oBFusCATed on November 08, 2010, 02:57:13 PM
Quote from: MortenMacFly on November 08, 2010, 02:11:17 PM
...This is a structure and if you only set the first value to zero, the other values may still be invalid on initialisation (platform / compiler dependent).
Hm, C++ standard says that the unspecified members are initialized with zero (If I remember correctly).
I can sure it, so, I think it maybe not needed to hack.
But it should be
SCNotification scn = {{0}};

No, you can use just {0}.
See:
#include <iostream>

using namespace std;

struct A
{
   int i;
   float j;
   char c;
   int* p;
};

int main()
{
   A a = {0};
   cout << a.i << "," << a.j << "," << a.c << "," << a.p << endl;
   return 0;
}

Jenna

It's not correct in our case, because the first element of the struct is a struct, that needs to be initialised with {0} itself.
All other elements are set to zero (or their default values ?) automagically.

#include <iostream>

using namespace std;

struct B
{
    int j;
};

struct A
{
    struct B b;
    int i;
    float j;
    char c;
    int* p;
};

int main()
{
    A a = {0};
    cout << a.b.j << "," << a.i << "," << a.j << "," << a.c << "," << a.p << endl;
    return 0;
}


leads to warning:
main.cpp:21:13: warning: missing braces around initializer for 'B'
even if it works.

MortenMacFly

Quote from: jens on November 08, 2010, 05:29:17 PM
It's not correct in our case, because the first element of the struct is a struct, that needs to be initialised with {0} itself.
All other elements are set to zero (or their default values ?) automagically.
That's what I meant: For me it is not really clear what is fully correct. Even if it may work due to the standard (what does the standard say about initialising structs within structs btw?!) as it is now - it'll definitely work reliable.

So again my question: What's the issue with it?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Loaden

Quote from: jens on November 08, 2010, 05:29:17 PM
It's not correct in our case, because the first element of the struct is a struct, that needs to be initialised with {0} itself.
All other elements are set to zero (or their default values ?) automagically.

leads to warning:
main.cpp:21:13: warning: missing braces around initializer for 'B'
even if it works.
In VC++2010, their have no warning when use {0} to initialize a struct member variable.
So, We can avoid this warning in project settings.
This is C++ standard behavior. So, don't worry, all the member will initialize to zero.
Include struct member value. :)

Loaden

Quote from: MortenMacFly on November 08, 2010, 08:13:01 PM
So again my question: What's the issue with it?
This will increase the difficulty of maintenance.
I think we should change the scintilla/wxScintilla as little as possible.

Loaden

Quote from: Loaden on November 08, 2010, 04:42:20 PM
Quote from: jens on November 08, 2010, 12:21:17 PM
Can you test my new patch, works for me on XP SP3, wx2.8.10 and TDM gcc 4.5.0 (just for the core project-file at the moment).
Well done! testing passed.
And have a issue, I think we need change the lib name from "libwxscintilla.a" to "libcbscintilla.a" or "libwxscintilla_cb.a".
Because in wx2.9.x, the wxscintilla library named "libwxscintilla.a" too. :)
Any comments about the library name?

BTW, I am testting in XPSP3, if build wxScintilla as static library, the core (not include contrib) result is : 16.5MB.
And, If build wxScintilla as shared library, the core reulst is 16.5 MB too.
In fact, only codeblocks.dll size have changed.
DLL Name static build shared build
codeblocks.dll 4.76MB 3.62MB

Loaden

#37
Here is a patch for wx2.9.2, build wxScintilla as static library too. :lol:

Biplab

If a struct is inside struct and we want to initialize it to zero we need to enclose it with { } Thus gcc was throwing warning on the original code.

So correct form should be -
struct foo f = { {0}, 0};

M$VC not being standard compliant can ignore such code. :)
Be a part of the solution, not a part of the problem.

MortenMacFly

Quote from: Biplab on November 09, 2010, 03:37:26 AM
struct foo f = { {0}, 0};
That sounds reasonable to me. If that removes the error and is standard compliant we can go for it. However, we would still have these portions in the code patched than... ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

oBFusCATed

Quote from: Biplab on November 09, 2010, 03:37:26 AM
M$VC not being standard compliant can ignore such code. :)
You're wrong here :)

This warning is specific to GCC, here is an explanation: http://www.mail-archive.com/gcc@gcc.gnu.org/msg47795.html
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Biplab

Quote from: MortenMacFly on November 09, 2010, 09:30:27 AM
Quote from: Biplab on November 09, 2010, 03:37:26 AM
struct foo f = { {0}, 0};
That sounds reasonable to me. If that removes the error and is standard compliant we can go for it. However, we would still have these portions in the code patched than... ;-)

Agreed. :)


Quote from: oBFusCATed on November 09, 2010, 09:51:44 AM
Quote from: Biplab on November 09, 2010, 03:37:26 AM
M$VC not being standard compliant can ignore such code. :)
You're wrong here :)

This warning is specific to GCC, here is an explanation: http://www.mail-archive.com/gcc@gcc.gnu.org/msg47795.html


I can't go through the link at the moment. But if I understand clause 8.5.1.8 of N1905-05-0165 correctly draft standard shows how it should be initialized.

I agree that I am not be correct in saying M$VC compiler is not standard compliant when the standard is a draft one. :)
Be a part of the solution, not a part of the problem.