Skip to content
QtWS25 Last Chance
  • 0 Votes
    10 Posts
    625 Views
    A

    For anyone interested, I've started a set of such bindings here: https://github.com/seaqt/seaqt-gen - the output can be seen here: https://github.com/seaqt/seaqt - the project is based on miqt (go bindings) with the aim to expose as much functionality as possible to C such that it can be imported into any language that has good FFI / C interop capabilities (such as https://nim-lang.org/), though there is of course nothing preventing the use of these bindings from C natively - the generated code is actually pretty simple to follow / use.

  • 0 Votes
    1 Posts
    968 Views
    No one has replied
  • How to use fprintf?

    Unsolved General and Desktop
    9
    0 Votes
    9 Posts
    7k Views
    kshegunovK

    @JohanSolo

    Your first trial should have difficulties to compile, or should at least crash when running, the char and int sizes are different: your read_buff is char*, i.e. each element is 1 byte, whilst the "%d" expects an object of at least 4 bytes.

    While I agree in principle, most compilers don't care. This is C with variadic function(s) which basically means you can forget type-safety. What's happening is that fprintf if just reading memory it doesn't own (which most compilers will allow freely, i.e. it won't crash).

    @Anas_Deshmukh

    int empId1; // some integer FILE * pun; // file pointer char read_buff[] = { 0xAA, 0x2D, 0xFF }; // char array holding value as 0xAA, 0x2D, 0xFF . . . int read_buff_size = 3; //< Size of the above buffer (in elements)

    You can do it like this:

    QFile file; if (!file.open(pun, QFile::WriteOnly)) { // Can't open, error handle accordingly. } QTextStream out(&file); out << empId1; for (qint32 i = 0; i < read_buff_size; i++) out << "~0x" << QString::number(read_buff[i], 16); out << endl; file.close(); // Do not forget to close the FILE *

    Kind regards.

  • 0 Votes
    9 Posts
    4k Views
    SGaistS

    Hi @asthana-ujjwal and welcome to devnet,

    Can you show your .pro file ?