#How to compile/ make this to be 64-bit

20 messages · Page 1 of 1 (latest)

quasi nexus
#
// Function to save a vector of DataArray to a binary file
void saveDataToFile(const std::vector<KlineDataArray>& data, const std::string& filePath) 
{
    std::ofstream outFile(filePath, std::ios::binary);
    if (!outFile.is_open()) 
    {
        std::cerr << "Failed to open file for writing: " << filePath << '\n';
        return;
    }

    size_t dataSize{ data.size() };
    outFile.write(reinterpret_cast<const char*>(&dataSize), sizeof(size_t));
    outFile.write(reinterpret_cast<const char*>(data.data()), dataSize * sizeof(DataArray));

    //uint64_t dataSize = static_cast<uint64_t>(data.size());
    //outFile.write(reinterpret_cast<const char*>(&dataSize), sizeof(uint64_t));
    //outFile.write(reinterpret_cast<const char*>(data.data()), dataSize * sizeof(DataArray));
}

for some reason it still compiles / acts as a 32 bit instead of 64 bit. I do g++ -O3 -std=c++23 -m64 -o env environment.cpp and i have checked g++ -v
which ouptus:

Using built-in specs.
COLLECT_GCC=C:\msys64\ucrt64\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-13.2.0/configure --prefix=/ucrt64 (and so on)
pallid boneBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

river topaz
#

for some reason it still compiles / acts as a 32 bit
how do you know its acting 32 bit?

quasi nexus
river topaz
#

ah

#

wait no you're just unlucky here

#

I think write will max to 32 bit signed integer regardless

quasi nexus
#

bruh

river topaz
#

in some cases

river topaz
# quasi nexus bruh

you can check the size of a pointer though to know if youre on 64 bit or 32

#
std::cout << CHAR_BIT * sizeof(void*);
#

should output 64 if youre on a 64 bit system and 32 if youre on 32

river topaz
#

if the implementors chose ptrdiff_t (which they might have as its used for signed size_t in other splace) then this could be restricted to 32 bit

quasi nexus
river topaz
quasi nexus
#

!solved