cs50 / problems

Checks for check50
134 stars 227 forks source link

Speller source version differs from distro code #233

Closed curiouskiwi closed 6 months ago

curiouskiwi commented 6 months ago

The version of speller.c that is used by check50 has an extra header #include <unistd.h> that is not in the problem set's distro version.

If a student happens to create a new function using a name that is an existing function in unistd.h, check50 will fail to compile with an error code of 2, due to the mismatched prototypes.

Example

extraheaders.c:4:6: error: conflicting types for 'read'
void read(char *);
     ^
/usr/include/unistd.h:371:16: note: previous declaration is here
extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
               ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]

But the student will have no way to see this as it will compile fine in the codespace using the distro version of speller.c

@rongxin-liu Is that header actually required here? And if so, should it be added to the distro version? Or removed?

In either case, we should try to get the #includes in sync.

rongxin-liu commented 6 months ago

#include <unistd.h> does look unnecessary here, removed.

Thanks for reporting! @curiouskiwi https://github.com/cs50/problems/commit/b065bd94ab8ed21ed9fa9fc2fb7d6a3b22382528