peytonk132 / FortIDE

This is a simple Fortran-deidcated IDE im making. This is the Reddit post kind of describing the things I want to do and a run down of who I am: https://www.reddit.com/r/AskProgramming/comments/1c0bat6/making_a_simple_ide_for_fortran
Other
5 stars 2 forks source link

ParseTreeType.h(17,5): error C2143: syntax error: missing '}' before 'constant' #8

Closed kaby76 closed 1 week ago

kaby76 commented 3 weeks ago

The problem is from a #define ERROR 0 in wingdi.h, which is part of the VS2022 standard library. It is being included by windows.h. You're going to have to partition the code that uses Antlr4 runtime from all your other code. That means you have to write a header .h file that declares a class with some parsing functionality, and a .cpp with the implementation. Then, you can include the .h in mainfunc.cpp. In other words, you cannot include any antlr4 runtime .h files and windows.h.

peytonk132 commented 3 weeks ago

So, you said that it was designed for me to link the .vcxproj file to my current project, how would I do that?

kaby76 commented 3 weeks ago

Correct. The first thing to do is to redo how you get the dependencies. I wrote this little Bash script that does git clones and curl. It's likely not complete.

#
rm -rf deps
mkdir deps
pushd deps
git clone https://github.com/ocornut/imgui.git; pushd imgui; git checkout v1.91.0; popd
git clone https://github.com/antlr/antlr4.git; pushd antlr4; git checkout 4.13.2; popd
git clone https://github.com/SFML/imgui-sfml.git; pushd imgui-sfml; git checkout v2.6; popd
git clone https://github.com/SFML/SFML.git; pushd SFML; git checkout 2.6.1; popd
git clone https://github.com/nlohmann/json.git; pushd json; git checkout v3.11.3; popd
git clone https://github.com/boostorg/boost.git; pushd boost; git checkout boost-1.85.0; popd

curl https://archives.boost.io/release/1.82.0/source/boost_1_82_0.zip -o boost_1_82_0.zip
popd

You can easily rewrite this as Pwsh.exe script or even Cmd.exe script if you have to. But, you want all dependencies readily available from scratch, not plopped somewhere on your system. Eventually, you should have Github Actions to at least build, if not also test, your program, so getting all the dependencies will be required.

peytonk132 commented 3 weeks ago

Thank you so much, I'm going to leave this open for now in case I have any issues. I've never really looked into good project management so it's never crossed my mind really.

peytonk132 commented 3 weeks ago

So, I followed your instructions that did work in the end. I linked the vcxproj file with my project added the dll file to where the exe is being created and linked to where the lib would be. After all that I still got a number of errors like:

1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(167,40): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(167,40): error C2086: 'int *input': redefinition
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>    C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(165,49):
1>    see declaration of 'input'
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(167,92): error C2143: syntax error: missing ';' before '&'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(167,66): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(167,47): warning C4228: nonstandard extension used: qualifiers after comma in declarator list are ignored
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(167,100): error C2059: syntax error: ')'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(167,93): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(167,93): error C2530: 'options': references must be initialized
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(169,4): error C2588: '::~Fortran90Parser': illegal global destructor
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(169,4): error C3158: 'Fortran90Parser': 'override' can only be applied to a virtual member function
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(169,4): error C2575: 'Fortran90Parser': only member functions and bases can be virtual
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(169,4): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(171,15): error C2270: 'getGrammarFileName': modifiers not allowed on nonmember functions
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(171,15): error C3158: 'getGrammarFileName': 'override' can only be applied to a virtual member function
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(173,27): error C2270: 'getATN': modifiers not allowed on nonmember functions
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(173,27): error C3158: 'getATN': 'override' can only be applied to a virtual member function
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(175,35): error C2270: 'getRuleNames': modifiers not allowed on nonmember functions
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(175,35): error C3158: 'getRuleNames': 'override' can only be applied to a virtual member function
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(177,34): error C2270: 'getVocabulary': modifiers not allowed on nonmember functions
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(177,34): error C3158: 'getVocabulary': 'override' can only be applied to a virtual member function
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(179,34): error C2270: 'getSerializedATN': modifiers not allowed on nonmember functions
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(179,34): error C3158: 'getSerializedATN': 'override' can only be applied to a virtual member function
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(1223,41): error C2059: syntax error: '<parameter-list>'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(1223,43): error C2238: unexpected token(s) preceding ';'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(1384,35): error C2059: syntax error: '<parameter-list>'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(1384,37): error C2238: unexpected token(s) preceding ';'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(1385,36): error C2059: syntax error: '<parameter-list>'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(1385,38): error C2238: unexpected token(s) preceding ';'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(1890,41): error C2059: syntax error: '<parameter-list>'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(1890,43): error C2238: unexpected token(s) preceding ';'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(2023,35): error C2059: syntax error: '<parameter-list>'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(2023,37): error C2238: unexpected token(s) preceding ';'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(2052,41): error C2059: syntax error: '<parameter-list>'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(2052,43): error C2238: unexpected token(s) preceding ';'
1>(compiling source file 'mainfunc/mainfunc.cpp')
1>C:\Users\Peyton\Documents\dev\FortIDE\mainfunc\F90Files\Fortran90Parser.h(2052,43): error C1003: error count exceeds 100; stopping compilation
1>(compiling source file 'mainfunc/mainfunc.cpp')

I eventually figured out that the errors would come out when it went to compile mainfunc.cpp. At first I thought that was the code in the error detection function so I removed that and replaced it with a printf debugging statement. That didn't work though so I fugured maybe it was the lexer, parser, and runtime files. I commented them out and it compiled fine and ran fine. I then went back and made three different tests of including each file on it's own in mainfunc.cpp and it still gave errors. I thought maybe you could figure something out or if perhaps it's a step I forgot to do that i'm just not realizing?

peytonk132 commented 3 weeks ago

Nevermind, my idiot self didn't pickup on the first thing he said about it being a conflict between including windows.h and the other headers. I made a simple function separate from mainfunc.cpp and it worked fine and it compiles.