Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'size_t' to 'int' conversion in 64Bit builds #5868

Open
psychofisch opened this issue Feb 3, 2018 · 7 comments
Open

'size_t' to 'int' conversion in 64Bit builds #5868

psychofisch opened this issue Feb 3, 2018 · 7 comments

Comments

@psychofisch
Copy link

While I tried to clean up some code in one of my projects I found a lot of warnings in 'ofMatrix4x4.h'.
These warnings come up, because a lot of methods in that class use 'std::size_t' as parameter for 'row' and 'col'. This is no warning in 32Bit builds, because they are both (at least) 32Bit long but it generates a warning in 64Bit, where 'size_t' has to be (at least) 64Bit long.
Why are these parameters 'size_t' when, most of the time, they only specify values from 0 to 4?

@arturoc
Copy link
Member

arturoc commented Feb 6, 2018

@bakercp this was originally int but it seems you changed it to size_t in 235fede#diff-2520147a1908de2c6127ab61b8b41e97L319.

Can you take a look?

@bakercp
Copy link
Member

bakercp commented Feb 7, 2018

@psychofisch Because operator indices are typically defined as a size_type - which are usually synonyms for std::size_t (http://en.cppreference.com/w/cpp/types/size_t). Using std::size_t helps prevent accidental negative indices, etc. We are moving to std::size_t for any index in the oF base (because std::vector, etc returns std::size_t when asking for size(), etc). After reviewing the code I can't find anywhere that would require a cast to int -- can you give me some lines where you are getting these warnings?

Without seeing your code, my guess is that you are passing int to the new methods that take std::size_t and you need to explicitly cast to std::size_t or change your index to std::size_t which is the "right" data type for array indices (subject to debate of course :)) to get rid of the warnings.

@psychofisch
Copy link
Author

psychofisch commented Feb 7, 2018

You can try to build any of the example projects with 64Bit.
For example: in the 3DPrimitivesExample sample I get 13 warning regarding this issue. (>500 when rebuilding the solution, all in openframeworksLib)
EDIT: sorry for not adding some additional information -> Visual Studio Community 2015, Windows 10 Pro and OF v0.9.8

@bakercp
Copy link
Member

bakercp commented Feb 7, 2018

OF v0.9.8? Do you get the issues with the master branch? That's were all of the fixes were made -- I expect there are still tons of warnings / issues in 0.9.8.

@psychofisch
Copy link
Author

I'm currently not able to build the master branch, because download_libs.ps1 keeps failing on line 123. I'll report back as soon as I fixed that problem.

@arturoc
Copy link
Member

arturoc commented Feb 8, 2018

@psychofisch that should be fixed now

@psychofisch
Copy link
Author

So I was able to use the script and download the libs for vs2015 and these are the warnings I get when building "3DPrimitivesExample" for 64Bit.
of_size_t_int

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants