Amrane Abdelkader
Amrane Abdelkader

Reputation: 145

Prevent my project from calling the __CxxFrameHandler3 (CRT function)

I was working on a none Visual C++ Runtime Library project for a few days from now, however, I had a smooth ingoing until my linker start complaining about the unresolved external symbol of the __CxxFrameHandler3 CRT function, so after searching for the reason which produces this error I found that calling a method of any custom class from the main entry point is calling this CRT function, simple example :

// /No Common Language RunTime Support
// /Ignore All Default Libraries 

class A
{
public:
    A();
    ~A();

    int do_something();
private:

};

int A::do_something()
{
    return 0;
}

int EntryPoint()
{
    A a;
    a.do_something(); // Calls the __CxxFrameHandler3 CRT function.

    return 0;
}

Error :

 LNK2019    unresolved external symbol ___CxxFrameHandler3 referenced in function __unwindfunclet$?UmbraServerMain@@YGHPAUHINSTANCE__@@0PA_WH@Z$0   

Is there a way to prevent the call to this CRT function?

Upvotes: 2

Views: 5487

Answers (2)

SergeyA
SergeyA

Reputation: 62583

Reposting my comment as an answer:

This functions has to do with SEH (Structured Exceptions Handling), so to stop calling it, one needs to disable exceptions (SEH and C++ exceptions) in the project.

Upvotes: 5

cHao
cHao

Reputation: 86524

That function is part of VS's exception handling infrastructure. In order to safely avoid using the CRT, you'll need to either provide your own (compatible!) implementations of the exception-handling functions, or compile with exceptions disabled and religiously avoid anything that can throw an exception. (An exception you've explicitly unprepared yourself for, is a memory leak waiting to happen.)

Upvotes: 1

Related Questions