Printing a size_t variable results in a warning C2467

G

Guest

Hi,
When I try to print the value of a size_t variable in a stream, I get a
warning.

My code looks as follows.


#include <cstddef> //size_t
#include <cstdlib> //EXIT_SUCCESS
#include <iostream>


int main() {
size_t num = 5;
std::cout << num << std::endl;
return EXIT_SUCCESS;
}


When I try to compile - I get

" d:\akkumar\personal\ng\vs7\ngcpp\ngcpp\sizetprint.cpp(8) : warning C4267:
'argument' : conversion from 'size_t' to 'unsigned int', possible loss of
data "

I don't understand this . I am not converting any data here . Is it that
the operator >> is not overloaded for type size_t ? Anyone got any
suggestions to get around this warning ?
 
D

David Lowndes

When I try to print the value of a size_t variable in a stream, I get a

Try switching off the compiler 64-bit portability warning (/Wp64) and
see if it goes away.

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top