What about the types int2, int3, float2, float3 etc

后端 未结 5 997
孤城傲影
孤城傲影 2020-12-20 13:03

I\'ve seen different code snippets using these types, but I haven\'t seen if they are defined in some or just defined in a \"local header file\"

相关标签:
5条回答
  • 2020-12-20 13:09

    These types aren't a part of standard C++. They might either be defined in some third-party library, or you're looking at some other dialect or language.

    GPU code (Shader languages such as GLSL, Cg or HLSL, or GPGPU stuff like CUDA or OpenCL) typically defines types like these though, as names for the corresponding SIMD datatypes.

    0 讨论(0)
  • 2020-12-20 13:11

    They are used in CUDA (and openCL?) where you have specific sized floats and memory usage and alignment is a big deal.

    0 讨论(0)
  • 2020-12-20 13:20

    AFAIK there is no standard header file that defines these types. According to your description int2 means a pair of two ints which can be represented in C++ as std::pair<int, int>.

    0 讨论(0)
  • 2020-12-20 13:30

    I stay with the POSIX types defined in <stdint.h>. It seems like everyone defines their own names for things and I've had a project where the names collide. It's become a new paradigm for me to NOT define my own "pet" names for types.

    0 讨论(0)
  • 2020-12-20 13:31

    These types are not standard and I've never seen them. Are you sure they weren't used as (terrible choices of) identifiers instead of types?

    Some non-standard types that are quite likely available anyway are int32_t, uint64_t, etc. (These are specified by C99, so most modern C++ compilers also let you use them in C++.)

    0 讨论(0)
提交回复
热议问题