Author Topic: missing 'const' in CompilerCommandGenerator::GetOrderedOptions(...)  (Read 4007 times)

mdelfede

  • Guest
There's a missing 'const' in sdk/CompilerCommandGenerator.cpp :

** Arrange order of options.
  * Depending on the order defined for the build target, it concatenates
  * @c project_options with @c target_options and returns the result.
  */
wxString CompilerCommandGenerator::GetOrderedOptions(ProjectBuildTarget* target, OptionsRelationType rel, const wxString& project_options, const wxString& target_options)


should be

wxString CompilerCommandGenerator::GetOrderedOptions(const ProjectBuildTarget* target, OptionsRelationType rel, const wxString& project_options, const wxString& target_options)

GCC complains about it.

Ciao

Max

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: missing 'const' in CompilerCommandGenerator::GetOrderedOptions(...)
« Reply #1 on: July 13, 2006, 09:12:40 pm »
My compiler (which happens to be gcc) does not complain about it (and I see no reason why target should be const, either).

Mind posting the full commandline including the exact error message?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

mdelfede

  • Guest
Re: missing 'const' in CompilerCommandGenerator::GetOrderedOptions(...)
« Reply #2 on: July 13, 2006, 09:14:54 pm »
My compiler (which happens to be gcc) does not complain about it (and I see no reason why target should be const, either).

Mind posting the full commandline including the exact error message?

Sorry, I forgot the revision, is 2746.
I'll take off the 'const' again and post the mesage...

Here is it :

:: === Code::Blocks, sdk ===
sdk\compilercommandgenerator.cpp:581: error: prototype for `wxString CompilerCommandGenerator::GetOrderedOptions(ProjectBuildTarget*, OptionsRelationType, const wxString&, const wxString&)' does not match any in class `CompilerCommandGenerator'
sdk\compilercommandgenerator.h:42: error: candidate is: virtual wxString CompilerCommandGenerator::GetOrderedOptions(const ProjectBuildTarget*, OptionsRelationType, const wxString&, const wxString&)
:: === Build finished: 2 errors, 0 warnings ===

btw, or the 'target' must be 'const' in cpp file, or he mustn't be const in header file....

Ciao

Max
« Last Edit: July 13, 2006, 09:17:53 pm by mdelfede »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: missing 'const' in CompilerCommandGenerator::GetOrderedOptions(...)
« Reply #3 on: July 13, 2006, 09:28:19 pm »
Ah, ok... this was introduced in 2746 and fixed in 2747   :)

You're right, the function's signature was changed.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: missing 'const' in CompilerCommandGenerator::GetOrderedOptions(...)
« Reply #4 on: July 13, 2006, 10:24:37 pm »
woops my mistake, somethin went wrong in my merge. My scratch svn was ok, but my commit svn, I forgot the implementation to the change. Sorry ...

By the way, that way you could not see my comment I made to the source ;-)
Code
wxString CompilerCommandGenerator::GetOrderedOptions(const ProjectBuildTarget* target, OptionsRelationType rel, const wxString& project_options, const wxString& target_options)
{ // NOTE : this should not be a member method, does not use nor alter the state


By the way, it should be const, since nothing is bound to change to the target argument.