ihedvall / mdflib

Implementation of the ASAM MDF data file.
https://ihedvall.github.io/mdflib/
MIT License
76 stars 32 forks source link

error: could not convert ‘0’ from ‘int’ to ‘fpos_t’ #2

Closed Murmele closed 2 years ago

Murmele commented 2 years ago
mdflib/src/iblock.h:131: Fehler: could not convert ‘0’ from ‘int’ to ‘fpos_t’
In file included from mdflib/src/pr3block.h:8,
                 from mdflib/src/pr3block.cpp:8:
mdflib/src/iblock.h:131:27: error: could not convert ‘0’ from ‘int’ to ‘fpos_t’
  131 |   fpos_t file_position_ = 0;       ///< 64-bit file position.
      |                           ^
      |                           |
      |                           int

If I am looking into the definition of fpos_t it is a struct and not just a number image

Murmele commented 2 years ago

The problem is that fpos_t is defined differently on different platforms

Murmele commented 2 years ago

According to the reference, fpos_t is used incorrectly: https://cplusplus.com/reference/cstdio/fpos_t/

only using fgetpos and fsetpos are defined functions

ihedvall commented 2 years ago

This is a bug. The MDF3 uses 32-bit (uint32_t) file position while the MDF4 uses 64-bit file position (int64_t). I had problem earlier with setting and getting file position which depends on the compiler.

The solution is to remove all fpos_t and fgetpos... from the source code and isolate all that code in one place.

The iblock.h/cpp shall do all file position setting and getting. I can fix the bug but I suspect this is not the last bug related to this.

ihedvall commented 2 years ago

I have isolated the fpos_t problem to the Iblock.cpp file functions Get/SetFilePosition(). The current solution may work but I don't have all platforms available so some ifdef might be required in these functions. Is it possible for you to test?

Murmele commented 2 years ago

Hello @ihedvall . I try to fix all issues on linux and try to setup a ci for automated tests. I will create a pullrequest after I have a good state, sp you can have a look

Murmele commented 2 years ago

There are quite a lot ifdes to add but it is going forward

ihedvall commented 2 years ago

Note that I checked in changes. All fpos_t related thing should be in 2 functions in src/iblock.cpp.

Murmele commented 2 years ago

Thanks I will rebase tomorrow my branch and go on with replacing windows specific functions by c++ std or ifdefs.