char const* linkage problems

D

Dr. Leff

I am having toruble with char const * material in an older program
that
I downloaded and am trying to get working. I am compiling in Visual C
++

Here is the error message
load_font
1>TextImpl.obj : error LNK2019: unresolved external symbol
"int __cdecl load_font(char const *)" (?load_font@@YAHPBD@Z)
referenced in function
"public: __thiscall TextImpl::TextImpl(class View *,int,double,
double,char *,char const *,char const *,int)"
(??0TextImpl@@QAE@PAVView@@HNNPADPBD2H@Z)

Here is the relevant part of the program:

char F[10000] ;
strcpy (F,fname);
if (fname)
fontid = load_font(F);
else
fontid = inq_font();

And this is how it is declared in another procedure:

int
load_font( char *fontname)

Dr. Laurence Leff Western Illinois University, Macomb IL 61455 ||
(309) 298-1315
Stipes 447 Assoc. Prof. of Computer Sci. Pager: 309-367-0787 FAX:
309-298-2302
 
I

Ian Collins

Dr. Leff said:
I am having toruble with char const * material in an older program
that
I downloaded and am trying to get working. I am compiling in Visual C
++
Here is the relevant part of the program:

char F[10000] ;
strcpy (F,fname);
if (fname)
fontid = load_font(F);
else
fontid = inq_font();

And this is how it is declared in another procedure:

int
load_font( char *fontname)
Not enough information, somewhere the function is being declared with
const char* as its parameter.

Why not change the definition?
 
A

alfps

I am having toruble with char const * material in an older program
that
I downloaded and am trying to get working.  I am compiling in  Visual C
++

Here is the error message
load_font
1>TextImpl.obj : error LNK2019: unresolved external symbol
"int __cdecl load_font(char const *)" (?load_font@@YAHPBD@Z)
referenced in function
"public: __thiscall TextImpl::TextImpl(class View *,int,double,
double,char *,char const *,char const *,int)"
(??0TextImpl@@QAE@PAVView@@HNNPADPBD2H@Z)

Here is the relevant part of the program:

char F[10000] ;
   strcpy (F,fname);
   if (fname)
      fontid = load_font(F);
   else
      fontid = inq_font();

Consider using std::string or some other abstract string class.

Also, consider making everything 'const', where at all possible (this
helps the compiler help you).

E.g.,

int const fontid = (fname[0] == 0? inq_font() : load_font(fname));

And this is how it is declared in another procedure:

int
load_font( char *fontname)

Ian Collins has already answered this, but note that this is not the
declaration you're using.

The declaration you're using has a 'const' for the argument.

Not sure what you mean by "in another procedure", probably that just
means "elsewhere"?


Cheers & hth.,

- Alf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,049
Members
48,769
Latest member
Clifft

Latest Threads

Top