Git Product home page Git Product logo

Comments (3)

Reticulatas avatar Reticulatas commented on May 11, 2024

I figured this out. I'm not sure why, but the build succeeds when I do:
#include <Magnum/Platform/Sdl2Application.h>
instead of
#include <Magnum/Magnum.h>

from magnum.

mosra avatar mosra commented on May 11, 2024

Hi!

It's not because of CMake, it's because most Magnum types are forward-declared unless you explicitly include the header the type is defined in. Which is the case of <Magnum/Magnum.h> that contains mainly just forward declarations of essential types, and to get the definition of Vector3 you have to #include <Magnum/Math/Vector3.h>. To make it easier for you, each API in the docs explicitly lists what header to include to get the full definition.

It worked with <Magnum/Platform/Sdl2Application.h> only because that header actually needs the full definition of the vector and so it includes <Magnum/Math/Vector3.h> on its own.

I admit that this might feel unusual at first, as <SomeLibrary/SomeLibrary.h> usually pulls in all types defined by given library. (For example Bullet, Eigen or Unreal does exactly that.) The reason for Magnum having just forward declarations in those headers is to optimize compilation times, see this part of the documentation for more information.

Hope this helps! :)

from magnum.

Reticulatas avatar Reticulatas commented on May 11, 2024

Thanks for the explanation, makes sense upon reading that doc!

Maybe a footnote in the example docs about includes linking to that page would be good?

from magnum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.