Frage

Ich habe ein Projekt mit __cdecl zusammengestellt Aufrufkonvention (msvc2010) und ich kompiliert boost den gleichen Compiler mit den Standardeinstellungen verwendet wird.

Das Projekt mit Boost verbunden, aber ich zur Laufzeit bekam ich eine Assertion Nachricht wie folgt aus: Datei: ... \ boost \ boost \ program_options \ Detail \ parsers.hpp Line: 79

Run-Time Check Failure # 0 - Der Wert von ESP nicht ordnungsgemäß über einen Funktionsaufruf gespeichert. Dies ist in der Regel ein Ergebnis des Aufrufs eine Funktion mit einer Aufrufkonvention deklarierte mit einem Funktionszeiger mit einer anderen Aufrufkonvention erklärt.

Es gibt folgende Fragen:

  • , welche Aufrufkonvention tut Boost Build mit standardmäßig auf Windows (msvc2010)
  • , wie ich Kompilierung Schub mit __cdecl Aufrufkonvention
  • warum Schub nicht in der Lage war, mit verschiedenen Aufrufkonventionen mit Code zu verhindern Verknüpfung? Ich verstand, dass Schub hat wirklich intelligenten Bibliothek Auto-Aufnahme-Code.

Update # 1

Es sieht aus, dass boost tut Kompilierung und Verknüpfung mit dem richtigen Aufrufkonvention, noch zur Laufzeit ich das oben genannte Problem zu bekommen. Ich habe eine Beispielanwendung mit dem gleichen Code und es funktioniert, aber in meiner Anwendung es funktioniert nicht. Der einzige Unterschied könnte von Projektkonfiguration oder includes / stdafx.h

War es hilfreich?

Lösung 3

I found the cause of the problem inside one of the shared property files: <StructMemberAlignment>4Bytes</StructMemberAlignment>

If I remove it the code will work. Still, I'm not sure why this is happening and how could I solve it without removing the above code (that was required by another library).

I added another question regarding boost and structure member alignment.

Andere Tipps

Just use

bjam ... **cxxflags=/Zp4**

while building boost libraries.

As far as I know there's not way to make C++ use cdecl calling conventions (see MSDN Calling Convention). The C++ method calling is just different from C. The only opportunity that you have to use one of the C calling conventions is for functions, which include class static functions in C++. If you know that's the case you can try forcing the option when building by adding the option during the build:

bjam cxxflags=/Gd ...

(see BBv2 Builtin features)

Or to make it "permanent" set up a user-config.jam with your compiler and add it to the build options for all BBv2 msvc builds (see BBv2 Configuration and related docs). As for you other questions:

  1. Boost uses the default calling convention MSVC uses, except for cases where it overrides it at the code level. I don't know where those are as they are library specific. So you'd have to search the code for the "__*" code decorators.
  2. See above for partial answer.
  3. Detection; there are two reasons: There is a limit to how many different options we can reasonably detect for for building as it's an exponential growth of different possible variations so we limit it to the most important cases. And in the case of calling convention, it's not actually possible since it's something that can be changed on a per function basis.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top