__sam__ a écrit : ↑17 sept. 2019 21:41
En fait le codeur, même (surtout?) s'il fait du C++ ne sait pas ce qu'il fait. J'en veut pour preuve ce commentaire:
dans lequel il mélange byte et bit. Il doit sans doute maîtriser un max les templates, la lib STL ,les itérateurs, le concept des visiteurs et de l'héritage (enfin j'espère, sinon ca sert à rien de faire du ++), mais ca n'en fait pas pour autant un bon codeur qui comprends ce qu'il fait et pourquoi ca marche (ou pas) ni pourquoi ca rame (preuve en est le ftell() super coûteux qui est appelé à chaque lecture d'octet, encore un qui croit que les appels systèmes se font à la même vitesse que les appels de fonctions dans l'espace utilisateur).
The use of "set byte 7 to 0" etc is from the original German coder - I know it is "clear bit 7" in English and will correct this minor comment.
However, the use of ftell etc in the routine read_byte_from_file (char *xd) was just a very quick and dirty method of reading in the data from a file.
The original PrinterToPDF did not show how we read the data (as this project came from our own Retro-Printer module -
www.retroprinter.com which reads data from GPIO pins, not from a file); but then people asked for an example of how they were supposed to read the data!
Yes, ideally, the file would be opened once and the file pointer would then update automatically, but the problem whenever you put some code like this in the wild is that people do not want to contribute - they expect the original author to do everything (and alas I do not have the time to do so).
Please feel free to contribute suggested improvements to the project if you want to see it used more widely.