-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the runtime parameter OPT__OUTPUT_TEXT_LENGTH_INT
#407
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChunYen-Chen I have a potentially major concern about the incompatibility between different integer types (e.g., int
and long
) for variadic functions like printf()
. For example, IIUC, the following code is invalid in general.
int a = 3;
printf( "%ld", a );
Given that OPT__OUTPUT_TEXT_FORMAT_INT
can be set rather arbitrarily (e.g., %12ld
, %12d
, or %12u
), it seems we cannot prevent such incompatibility issues from happening.
Possible solution:
- Allow users to specify only the length of the integer output (e.g.,
OPT__OUTPUT_TEXT_LENGTH_INT = 12
) - Always assume a long integer (
ld
) in the format specifier ofprintf()
- Explicitly cast integer arguments to
long
in function calls.
For example,
int temp = 3;
printf( "%*ld", OPT__OUTPUT_TEXT_LENGTH_INT, (long)temp );
What are your thoughts
Conflicts: src/Output/Output_DumpData_Total_HDF5.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Apply
OPT__OUTPUT_TEXT_LENGTH_INT
toPar_Output_TextFile.cpp
… into int_format
@hyschive Thanks for the review. I have updated the PR. |
OPT__OUTPUT_TEXT_FORMAT_INT
OPT__OUTPUT_TEXT_LENGTH_INT
Resolve #401.