User forums > Using Code::Blocks
Build messages settings and Find/Replace tool
oBFusCATed:
C::B supports, what wxRegEx supports.
Joshua Flynn:
Sorry for the delay in reply.
--- Quote from: Neil Butterworth on August 31, 2011, 11:42:09 am ---Not to do with your two main questions, but just to note that returning const values of any sort is kind of a waste of time in C++.
--- End quote ---
Const means read-only. Returning a bool (it was written on stack overflow {the website}), a user might attempt to over-write it (ReturnBool() = true), which would cause a crash (temporary variable?). It's extremely useful when passing by reference (so you know the variable being referred can't be altered). Generally good practice to make sure returning variables are read-only unless otherwise explicitly stated.
--- Quote from: oBFusCATed on August 31, 2011, 12:13:52 pm ---Yes, but this depends on the compiler, for gcc check the various -W options.
Then you set the options in Project->build options -> target -> compiler -> other (if there is no such option in the main options)
--- End quote ---
I think it's GCC. Is a pragma command possible?
--- Quote from: jens on August 31, 2011, 12:41:35 pm ---Just copy and paste, please do not post a screenshot, if it is not absolutely necessary.
--- End quote ---
--- Code: ---D\FileProcModular.h|21|warning: multi-character character constant|
D\FileProcModular.h|22|warning: multi-character character constant|
D\FileProcModular.h|23|warning: multi-character character constant|
D\FileProcModular.h|25|warning: multi-character character constant|
D\FileProcModular.h|26|warning: multi-character character constant|
D\FileProcModular.h|27|warning: multi-character character constant|
D\FileProcModular.h|29|warning: multi-character character constant|
D\FileProcModular.h|30|warning: multi-character character constant|
D\FileProcModular.h|31|warning: multi-character character constant|
D\FileProcModular.h|33|warning: multi-character character constant|
D\FileProcModular.h|34|warning: multi-character character constant|
D\FileProcModular.h|35|warning: multi-character character constant|
D\CharList.h||In member function 'const bool CharList::CopyBetweenStrings(const char*, const char*, const char*, bool)':|
D\CharList.h|504|warning: declaration of 'End' shadows a member of 'this'|
D\CharList.h|504|warning: declaration of 'Start' shadows a member of 'this'|
D\CharList.h|512|warning: unused variable 'C_Ptr_End'|
||=== Build finished: 0 errors, 15 warnings ===|
--- End code ---
--- Quote from: Freem on August 31, 2011, 02:02:31 pm ---There is a plugin in C::B to test your regex, too. (regular expressions testbed or something like that).
But I don't know exactly if C::B only use POSIX, or support PERL, or a mix between them, or a "POSIX-LITE".
--- End quote ---
Can you tell me valid regular expressions?
oBFusCATed:
bool myFunc() { return true; }
if (myFunc()=true) <-- this cannot crash, because the temporary is valid/alive until the closing brace!
const bool myFunc() is total waste of typing and then reading, keep in mind that reading code takes 90% of the time!
Some info const by a real guru: http://www.gotw.ca/gotw/081.htm
Please try the regular expression testbed plugin (it is in the plugins menu and you need the contrib plugins installed).
Keep in mind that using regular expressions require thinking and creativity, they are no silver bullet!
Joshua Flynn:
--- Quote from: oBFusCATed on August 31, 2011, 05:44:54 pm ---bool myFunc() { return true; }
if (myFunc()=true) <-- this cannot crash, because the temporary is valid/alive until the closing brace!
const bool myFunc() is total waste of typing and then reading, keep in mind that reading code takes 90% of the time!
Some info const by a real guru: http://www.gotw.ca/gotw/081.htm
--- End quote ---
Consider:
--- Code: ---class Test
{
public:
int A;
Test(){A = 0;}
};
const Test &ReturnTest1(){Test N; return N;}
const Test ReturnTest2(){Test N; return N;}
Test &ReturnTest3(){Test N; return N;}
Test ReturnTest4(){Test N; return N;}
int main(int ArgC, char *ArgV[])
{
ReturnTest1().A = 1; //Produces an access violation as it's const
ReturnTest2().A = 1; //Produces an access violation as it's const
ReturnTest3().A = 1; //No violation (as a reference this could be bad)
ReturnTest4().A = 1; //No violation (as a copy this would be pointless)
return 0;
}
--- End code ---
Even though C++ doesn't enforce const bools/ints/floats/chars, it does with classes, and it is a good habit to code consistently across the board, given that is the intention. Const at the start right away tells it's returning read-only (and thus shouldn't be modified anyway), and by making it the default (even if seemingly redundant), it becomes a habit that is applied to other classes.
It's a matter of indicating intentions. If I put const float (instead of const float&) by accident, anyone correcting that, knows the reference need to be read-only. If I put just float, a person could correct to float&, and thus it would be valid for the user to internally modify it. Not good.
--- Quote from: oBFusCATed on August 31, 2011, 05:44:54 pm ---Please try the regular expression testbed plugin (it is in the plugins menu and you need the contrib plugins installed).
Keep in mind that using regular expressions require thinking and creativity, they are no silver bullet!
--- End quote ---
Is there a manual I could read on the topic? I don't think I have that plugin installed.
oBFusCATed:
Probably this: http://wiki.codeblocks.org/index.php?title=Code::Blocks_Plugins
but there is no page for the regex testbed plugin, but it is pretty straight forward, just open the dialog :)
If you don't have you probably don't have the contrib plugins installed.
And as you've not mentioned anything about your computer: os, c::b version, compiler (not important here, but it is good to know!);
we can't tell you how to installed them.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version