exercism / exercism/c

C passes locally, not online (Compliation Flags)

Open
#699 13 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
383
Forks
215
PR merge metrics
No merged PRs in 30d

Description

I been working C grade_school and got the tests passing locally, but on submission I found that they had failed (what!!??) as follows:
```bash
./grade_school.c:10:6: error: no previous declaration for 'existing_student' [-Werror=missing-declarations]
bool existing_student(char name[]) {
^~~~~~~~~~~~~~~~
./grade_school.c:21:5: error: no previous declaration for 'compare_students' [-Werror=missing-declarations]
int compare_students(const void *a, const void *b) {
^~~~~~~~~~~~~~~~
./grade_school.c:28:11: error: no previous declaration for 'create_student' [-Werror=missing-declarations]
student_t create_student(uint8_t grade, char name[]) {
^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [makefile:37: tests.out] Error 1
```
Apparently, I need to include declarations for private functions (why?). What I don't understand why this issue isn't raised when I test locally? As far as I can see the make file includes flags for *missing-declarations*.

```bash
CFLAGS = -std=c99
CFLAGS += -g
CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -pedantic
CFLAGS += -Werror
CFLAGS += -Wmissing-declarations
CFLAGS += -DUNITY_SUPPORT_64
```

-- Added --

After further investigation I learned that that clang has a *-Weverything* compilation flag. Running with this set I can see numerous issues with my solution. It would seem that Clang is treating the [-Werror=missing-declarations] errors reported above as a [-Wmissing-prototypes] errors.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.