Skip to content
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

common.cpp printf() formats for [u]int64_t and size_t warnings #243

Open
leok7v opened this issue Jun 10, 2023 · 0 comments
Open

common.cpp printf() formats for [u]int64_t and size_t warnings #243

leok7v opened this issue Jun 10, 2023 · 0 comments

Comments

@leok7v
Copy link

leok7v commented Jun 10, 2023

While compiling on windows with cl.exe for x64 following warnings observed.

ggml\examples\common.cpp(353,21): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 2 has type 'size_t'
ggml\examples\common.cpp(353,21): message : consider using '%zu' in the format string
ggml\examples\common.cpp(353,21): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 3 has type 'unsigned __int64'
ggml\examples\common.cpp(353,21): message : consider using '%zu' in the format string
ggml\examples\common.cpp(353,21): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 2 has type 'size_t'
ggml\examples\common.cpp(353,21): message : consider using '%zu' in the format string
ggml\examples\common.cpp(353,21): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 3 has type 'unsigned __int64'
ggml\examples\common.cpp(353,21): message : consider using '%zu' in the format string
ggml\examples\common.cpp(353,21): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 2 has type 'size_t'
ggml\examples\common.cpp(353,21): message : consider using '%zu' in the format string
ggml\examples\common.cpp(353,21): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 3 has type 'unsigned __int64'
ggml\examples\common.cpp(353,21): message : consider using '%zu' in the format string
ggml\examples\common.cpp(353,21): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 2 has type 'size_t'
ggml\examples\common.cpp(353,21): message : consider using '%zu' in the format string
ggml\examples\common.cpp(353,21): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 3 has type 'unsigned __int64'
ggml\examples\common.cpp(353,21): message : consider using '%zu' in the format string

Nothing major or urgent but for clarity and easy of keeping in sync:

Maybe use:
#include <inttypes.h>
int64_t t;
printf("%" PRId64 "\n", t);

like: https://en.cppreference.com/w/cpp/types/integer

#include
#include

int main()
{
std::printf("%zu\n", sizeof(std::int64_t));
std::printf("%s\n", PRId64);
std::printf("%+" PRId64 "\n", INT64_MIN);
std::printf("%+" PRId64 "\n", INT64_MAX);

std::int64_t n = 7;
std::printf("%+" PRId64 "\n", n);

}

If you want pull request I can do the change but it's trivial to fix, maybe less trouble then reading the diff and accepting PR.

CCLDArjun pushed a commit to CCLDArjun/ggml that referenced this issue Dec 18, 2023
The readme tells people to use the command line option "-t 8", causing 8
threads to be started. On systems with fewer than 8 cores, this causes a
significant slowdown. Remove the option from the example command lines
and use /proc/cpuinfo on Linux to determine a sensible default.
CCLDArjun pushed a commit to CCLDArjun/ggml that referenced this issue Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant