Crates.io | code-errors |
lib.rs | code-errors |
version | 0.1.0 |
source | src |
created_at | 2022-12-31 20:10:32.452742 |
updated_at | 2022-12-31 20:10:32.452742 |
description | Command line tool to find errors in code! |
homepage | https://github.com/probro27/error-suggestion-tool |
repository | https://github.com/probro27/error-suggestion-tool |
max_upload_size | |
id | 748552 |
size | 36,964 |
Building a Command Line Tool which provides suggestions when developers face errors while coding!
code-errors gcc hello.c
.Run the following commands for MacOS:
brew tap probro27/tap
brew install code-errors
OPENAI_SK
. An example of setting this up in MacOS or Linux is placing export OPENAI_SK="<your_api_key>"
in ~/.bash_profile
and running source ~/.bash_profile
.code-errors <command>
.Write a hello.c
file with the code (bonus if you can find the obvious error)
#include <stdio.h>
int main() {
print("Hello world!");
return 0;
}
This looks like a simple hello world program. Let's compile it using our favourite complier gcc
.
Run: code-errors gcc hello.c
Result:
Result: Code: 1, error/output:
hello.c:4:5: error: implicit declaration of function 'print' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
print("Hello world!, %1f");
^
hello.c:4:5: note: did you mean 'printf'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer
/SDKs/MacOSX.sdk/usr/include/stdio.h:170:6: note: 'printf' declared here
int printf(const char * __restrict, ...) __printflike(1, 2);
^
1 error generated.
Suggestion is:
Suggestion:
The error message is telling that the implicit function 'print' is being used in line 4 -
it should either be changed to 'printf' or the library containing the definition of 'print' should
be included. It is also suggesting to include stdio.h header file which contains the definition
of printf() function.
Links:
1. Implicit function declaration - https://en.cppreference.com/w/c/language/implicit_declaration
2. printf() - https://en.cppreference.com/w/c/io/printf