Azure / azure-storage-cpplite

Lite version of C++ Client Library for Microsoft Azure Storage
MIT License
25 stars 43 forks source link

Type-limits warnings when building for ARM32 #72

Closed ryayl closed 4 years ago

ryayl commented 4 years ago

Use case: Implementing Azure Blob Storage on IoT Edge with C++ on ARM32 device, which is now supported using other languages such as Python, Node.

Issue: Trying to build on a 32-bit platform results in warnings due to assumptions about char size (I realize this code hasn't been tested on 32-bit officially):

/app/azure-storage-cpplite/src/blob/blob_client_wrapper.cpp: In member function 'void azure::storage_lite::blob_client_wrapper::upload_file_to_blob(const string&, const string&, std::cxx11::string, const std::vector<std::pair<std::cxx11::basic_string, std::__cxx11::basic_string > >&, size_t)': /app/azure-storage-cpplite/src/blob/blob_client_wrapper.cpp:421:25: error: comparison is always false due to limited range of data type [-Werror=type-limits] if(fileSize > MAX_BLOB_SIZE) ^ /app/azure-storage-cpplite/src/blob/blob_client_wrapper.cpp:429:25: error: comparison is always false due to limited range of data type [-Werror=type-limits] if(fileSize > (50000 * MIN_UPLOAD_CHUNK_SIZE)) ^ cc1plus: all warnings being treated as errors

Jinming-Hu commented 4 years ago

off_t is 32bit on ARM32, off64_t should work.

But I think off_t is part of POSIX standard, which our sdk should stay clear of, as a cross-platform project.

Anyway, blob_client_wrapper is not recommended to use, please use blob_client as possible as you can.

ryayl commented 4 years ago

Thanks, I can avoid blob_client_wrapper. This is more clear with the new sample code added recently.

It looks like off_t does the right thing which is to restrict fileSize to the range of whatever system you're on. Defining the macros as long long is more the problem. If they were defined as long I think they should be interpreted as 32bit on a 32bit system and 64bit on a 64bit system. But then you couldn't hard code MAX_BLOB_SIZE...