Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: linking error caused by function value parameter



Permlink Replies: 7 - Last Post: Oct 4, 2017 9:50 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Fraser Ross

Posts: 36
Registered: 1/15/99
linking error caused by function value parameter
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2017 5:49 AM
I had a project with 40 unresolved external linking errors. All of them
I have fixed by replacing const in function value parameters to BUGCONST
which I defined as /*const*/. I compiled using CB10.2 Tokyo and the
clang compiler. The classic compiler only made 2 of these errors. I
also have the Berlin compiler which is not any different. Is this
problem already known about?

Fraser.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: linking error caused by function value parameter
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2017 10:56 AM   in response to: Fraser Ross in response to: Fraser Ross
Fraser Ross wrote:

I had a project with 40 unresolved external linking errors. All of
them I have fixed by replacing const in function value parameters to
BUGCONST which I defined as const.

Let me see if I understand this correctly. You have a preprocessor
#define like this:

#define BUGCONST const


And you changed functions from doing things like this:

void function(const type param)


To doing this instead:

void function(BUGCONST type param)


Is that right? If so, there is NO POSSIBLE WAY that can fix linker
errors, since the compiler sees the exact same code after preprocessing
is done.

Something else is going on.

--
Remy Lebeau (TeamB)
Fraser Ross

Posts: 36
Registered: 1/15/99
Re: linking error caused by function value parameter
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2017 11:33 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
On 29/09/2017 18:56, Remy Lebeau (TeamB) wrote:
Fraser Ross wrote:

I had a project with 40 unresolved external linking errors. All of
them I have fixed by replacing const in function value parameters to
BUGCONST which I defined as const.

Let me see if I understand this correctly. You have a preprocessor
#define like this:

#define BUGCONST const


And you changed functions from doing things like this:

void function(const type param)


To doing this instead:

void function(BUGCONST type param)


Is that right? If so, there is NO POSSIBLE WAY that can fix linker
errors, since the compiler sees the exact same code after preprocessing
is done.

Something else is going on.

No const is defined surrounded by the comment block symbols using the
project options.

Fraser.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: linking error caused by function value parameter
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2017 12:56 PM   in response to: Fraser Ross in response to: Fraser Ross
Fraser Ross wrote:

No const is defined surrounded by the comment block symbols using the
project options.

Do you mean you are doing something like this?

#ifdef SOME_CONDITIONAL
#define BUGCONST /*const*/
#else
#define BUGCONST const
#endif


--
Remy Lebeau (TeamB)
Fraser Ross

Posts: 36
Registered: 1/15/99
Re: linking error caused by function value parameter
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 30, 2017 2:30 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
On 29/09/2017 20:56, Remy Lebeau (TeamB) wrote:
Fraser Ross wrote:

No const is defined surrounded by the comment block symbols using the
project options.

Do you mean you are doing something like this?

#ifdef SOME_CONDITIONAL
#define BUGCONST /*const*/
#else
#define BUGCONST const
#endif


No I use the project options (C++ Compiler, Directories and
Conditionals, Conditional Defines). In there I have placed
BUGCONST=/*const*/. When the linker is updated I can try setting it to
const.

Fraser.
Johannes Weinert

Posts: 90
Registered: 7/19/02
Re: linking error caused by function value parameter
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 3, 2017 11:14 PM   in response to: Fraser Ross in response to: Fraser Ross
Am 29.09.2017 um 14:49 schrieb Fraser Ross:
I had a project with 40 unresolved external linking errors. All of them
I have fixed by replacing const in function value parameters to BUGCONST
which I defined as /*const*/. I compiled using CB10.2 Tokyo and the
clang compiler. The classic compiler only made 2 of these errors. I
also have the Berlin compiler which is not any different. Is this
problem already known about?

Do you mean the problem does not happen with the 10.1 Berlin clang compiler?

If yes, you should consider to file a bug report.

I saw the problem only when the declaration of a method does not match
the definition, like:

A.h:
class A
{
   void Function( const int i );
};


A.cpp:
void A::Function( int i ) {}


or the other way round (const in the header is missing).

Regards

Hans
Fraser Ross

Posts: 36
Registered: 1/15/99
Re: linking error caused by function value parameter
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 4, 2017 1:49 AM   in response to: Johannes Weinert in response to: Johannes Weinert
On 04/10/2017 07:14, Johannes Weinert wrote:
Am 29.09.2017 um 14:49 schrieb Fraser Ross:
I had a project with 40 unresolved external linking errors. All of them
I have fixed by replacing const in function value parameters to BUGCONST
which I defined as /*const*/. I compiled using CB10.2 Tokyo and the
clang compiler. The classic compiler only made 2 of these errors. I
also have the Berlin compiler which is not any different. Is this
problem already known about?

Do you mean the problem does not happen with the 10.1 Berlin clang compiler?

If yes, you should consider to file a bug report.

I saw the problem only when the declaration of a method does not match
the definition, like:

A.h:
class A
{
    void Function( const int i );
};


A.cpp:
void A::Function( int i ) {}


or the other way round (const in the header is missing).

Regards

Hans

The problem is present with 10.1. I don't normally put const in the
header file because it does nothing and says nothing. I will make a
report later today.

Fraser.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: linking error caused by function value parameter
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 4, 2017 9:50 AM   in response to: Johannes Weinert in response to: Johannes Weinert
Johannes Weinert wrote:

I saw the problem only when the declaration of a method does not
match the definition

Why would you NOT expect a compiler/linker error in that case? Of
course they have to match. 'const' is part of the parmeter type. I
would expect a compiler error, before the linker is even called.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02