I have the following line of code:
printf("\n\nTime taken for simulation: %ld milliseconds\n", duration.count() );
On my home machine, I get the error,
main.cpp:292:65: error: format specifies type 'long' but the argument has type 'std::__1::chrono::duration<long long, std::__1::ratio<1, 1000>>::rep' (aka 'long long') [-Werror,-Wformat]
This error is sorted out if I change %ld to %lld
I use g++ -std=c++14. Home compiler version is:
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: arm64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
On the linux cluster I operate, if run it with %lld, I get the following error,
main.cpp:229:83: error: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘std::chrono::duration<long int, std::ratio<1, 1000> >::rep {aka long int}’ [-Werror=format=]
I use g++ -std=c++14. Cluster compiler version is:
g++ (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
if I change %lld to %ld, it is all good.
Is there a way I can print out duration.count(), where duration is defined as
auto duration = std::chrono::duration_cast<std::chrono::milliseconds> (stop-start);
where stop, start are variables of type specified by std::chrono::high_resolution_clock::now();.
Any advice you have would be appreciated.