Coder Social home page Coder Social logo

Comments (5)

nayuki avatar nayuki commented on July 18, 2024

(Related to http://stackoverflow.com/a/39951669/839689 and https://github.com/mrdeveloperdude/OctoMY/blob/master/libs/libqr/QrCode.cpp )

Hello Lennart! A couple of things going on here:

  • INT32_MAX is defined in stdint.h (a.k.a. cstdint). QrCode.cpp doesn't #include the header file, but it includes QrCode.hpp which does #include <cstdint>.
  • You may replace all int32_t with qint32, et cetera. My hunch is that this is just extra work without any benefit, because if I understand correctly, stdint.h should be supported pervasively by now.

from qr-code-generator.

mrdeveloperdude avatar mrdeveloperdude commented on July 18, 2024

from qr-code-generator.

nayuki avatar nayuki commented on July 18, 2024

That's a troubling discovery. If I understand correctly, stdint.h must be fully supported if the compiler supports C++11. I suggest some options for you:

  • Try writing std::INT32_MAX just in case that symbol is in the std namespace and not in the global namespace.
  • Try changing the include of cstdint to stdint.h (related to namespace conventions).
  • Simply write out the constant 2147483647, because INT32_MAX must have the same value on every platform (unlike INT_MAX).

from qr-code-generator.

mrdeveloperdude avatar mrdeveloperdude commented on July 18, 2024

from qr-code-generator.

nayuki avatar nayuki commented on July 18, 2024

It's okay to avoid using the using keyword. For one usage, it's probably better to write out the fully qualified name like std::INT32_MAX.

I think you're right that it is recommended to use <cstdint> instead of <stdint.h>. It agrees better with C++ conventions.

There is a general confusion about whether items that were defined globally in C are present globally in C++ or must be accessed through namespace std. See discussions like this for example: http://stackoverflow.com/questions/32606023/when-using-c-headers-in-c-should-we-use-functions-from-std-or-the-global-na

from qr-code-generator.

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.