Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2008

Tip: Looking for answers? Try searching our database.

Calling a static function from a class member method is giving     linking errors

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Omar.Khalid79@gmail.com - 20 Mar 2008 20:48 GMT
Hi Guys,

Maybe this is silly thing to ask but I have a static function declared

static void Foo(int a);

defined in Foo.cpp

and a member method which calls Foo

extern void foo(int a);
void A::Test
{
 int a = 0;
 foo(a);
}

I get linkage errors - 'un-resolved external symbol'. When I change
Foo to non-static, it works. Any ideas?
David Wilkinson - 20 Mar 2008 21:16 GMT
> Hi Guys,
>
[quoted text clipped - 15 lines]
> I get linkage errors - 'un-resolved external symbol'. When I change
> Foo to non-static, it works. Any ideas?

Omar:

Because, in this context, static means "to be used only in this translation
unit". This use of the static keyword is deprecated in C++; use unnamed
namespace instead.

Also, you do not need extern here.

Signature

David Wilkinson
Visual C++ MVP

Omar.Khalid79@gmail.com - 20 Mar 2008 22:31 GMT
> Omar.Khali...@gmail.com wrote:
> > Hi Guys,
[quoted text clipped - 30 lines]
>
> - Show quoted text -

Thanks David!!!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.