Author Topic: Code::Blocks, Scintilla and Fedora  (Read 41476 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Code::Blocks, Scintilla and Fedora
« Reply #30 on: November 08, 2010, 04:42:20 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. :)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Code::Blocks, Scintilla and Fedora
« Reply #31 on: November 08, 2010, 05:01:57 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
Code
SCNotification scn = {{0}};

No, you can use just {0}.
See:
Code
#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;
}
« Last Edit: November 08, 2010, 05:03:45 pm by Loaden »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Code::Blocks, Scintilla and Fedora
« Reply #32 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.
Code
#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:
Code
main.cpp:21:13: warning: missing braces around initializer for ‘B’
even if it works.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Code::Blocks, Scintilla and Fedora
« Reply #33 on: November 08, 2010, 08:13:01 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Code::Blocks, Scintilla and Fedora
« Reply #34 on: November 09, 2010, 12:53:18 am »
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:
Code
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. :)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Code::Blocks, Scintilla and Fedora
« Reply #35 on: November 09, 2010, 12:55:02 am »
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.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Code::Blocks, Scintilla and Fedora
« Reply #36 on: November 09, 2010, 01:24:05 am »
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.
Code
DLL Name		static build		shared build
codeblocks.dll 4.76MB 3.62MB

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Code::Blocks, Scintilla and Fedora
« Reply #37 on: November 09, 2010, 02:33:33 am »
Here is a patch for wx2.9.2, build wxScintilla as static library too. :lol:
« Last Edit: November 09, 2010, 02:38:55 am by Loaden »

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Code::Blocks, Scintilla and Fedora
« Reply #38 on: November 09, 2010, 03:37:26 am »
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 -
Code
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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Code::Blocks, Scintilla and Fedora
« Reply #39 on: November 09, 2010, 09:30:27 am »
Code
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code::Blocks, Scintilla and Fedora
« Reply #40 on: November 09, 2010, 09:51:44 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!]

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Code::Blocks, Scintilla and Fedora
« Reply #41 on: November 09, 2010, 10:33:34 am »
Code
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. :)


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.