Skip to content

Fix prototype mismatch of strlen() in libc.h #5

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

Merged
merged 1 commit into from
Jun 29, 2025

Conversation

visitorckw
Copy link
Collaborator

Commit f95a700 ("Correct return type of strlen function") changed the return type of strlen() from int32_t to size_t in its definition, but did not update the prototype in include/lib/libc.h accordingly. This causes a build failure due to a conflicting type declaration:

  CC    build/lib/libc.o
lib/libc.c:23:8: error: conflicting types for 'strlen'; have 'size_t(const char *)' {aka 'unsigned int(const char *)'}
   23 | size_t strlen(const char *s)
      |        ^~~~~~
In file included from lib/libc.c:1:
./include/lib/libc.h:73:9: note: previous declaration of 'strlen' with type 'int32_t(const char *)' {aka 'int(const char *)'}
   73 | int32_t strlen(const char *s1);
      |         ^~~~~~
make: *** [Makefile:53: build/lib/libc.o] Error 1

Update the strlen() prototype in the header file to match the new return type and fix the build error.

Fixes: f95a700 ("Correct return type of strlen function")

Commit f95a700 ("Correct return type of strlen function") changed the
return type of strlen() from int32_t to size_t in its definition, but
did not update the prototype in include/lib/libc.h accordingly. This
causes a build failure due to a conflicting type declaration:

  CC    build/lib/libc.o
lib/libc.c:23:8: error: conflicting types for 'strlen'; have 'size_t(const char *)' {aka 'unsigned int(const char *)'}
   23 | size_t strlen(const char *s)
      |        ^~~~~~
In file included from lib/libc.c:1:
./include/lib/libc.h:73:9: note: previous declaration of 'strlen' with type 'int32_t(const char *)' {aka 'int(const char *)'}
   73 | int32_t strlen(const char *s1);
      |         ^~~~~~
make: *** [Makefile:53: build/lib/libc.o] Error 1

Update the strlen() prototype in the header file to match the new
return type and fix the build error.

Fixes: f95a700 ("Correct return type of strlen function")
@jserv jserv merged commit c165af3 into sysprog21:main Jun 29, 2025
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

Successfully merging this pull request may close these issues.

2 participants