Listing fpos_t for int or char

I work with a function that uses bitwise operations with file length: fpos_t flen;

When I try to include it in int or char or try to perform an arithmetic operation on it, it will not execute the following compilation error: aggregate value used where an integer was expected

+4
source share
3 answers

You are using this type incorrectly. Firstly, it is not length. This is the position. Secondly, it is intended only for calling fsetpos . You do not have to do arithmetic because it does not necessarily mean a numeric type. It contains any information your library needs to perform the fsetpos operation. In your library implementation, fpos_t is represented as an aggregate type, for example, struct. (You can check the definition in the header files, but do not rely on what you find there, it may differ on other platforms or in future versions of the standard library.)

As for your next step, consider asking a more direct question about how to solve any problem you were working on when the idea arose of performing bitwise operations on fpos_t .

+5
source

I was getting the same error when I tried to do this: char aux = (char) flen and 15, where flen is fpos_t. I found a solution here: http://dsmarkchen.blogspot.com.br/2008/08/fpost.html . Must be: char aux = flen .__ pos and 15.

+2
source

It looks like you want to work with the current file position as an integer. If so, you probably want to use ftell / fseek (or their 64-bit brothers) rather than fgetpos / fsetpos. Both perform similar operations, but ftell / fseek work with integer values, and fgetpos / fsetpos work with a deliberately abstract structure.

0
source

Source: https://habr.com/ru/post/1387818/


All Articles