Open mithro opened 6 years ago
IMHO in C++, the iostreams is the correct approach.
I agree the type safety of iostreams is good, but they are somewhat painful to use in practise. I also find them much less readable than printf and friends.
VPR started out in C which is why large parts of the code base still use printf and friends.
I've contemplated switching to something like fmtlib which gives the best of both worlds (type-safe + readable). However there is a cost to using a non-standard library (any new developers would need to learn it). It would also be a fair amount of work to convert the code base to it.
There seems to be inconsistent usage of fprintf and iostreams in Verilog to Routing. I'm assuming this just comes about by having a bunch of different developers and no style guide telling you which one to use (and I think you did mention that the packer was originally a separate project from vtr?).
It looks like fprintf is slightly more popular, but I assume that is because it was used first.
What is your preference going forward? Should new code be using fprintf or iostreams?
Is it worth the effort doing a translation of the fprintf code into iostreams? (Going in that direction is pretty easy automatically, going in the other direction is much harder.)
Just a couple of quick greps;
fprintf usage
iostream usage