Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(C++) Stuck between a rock and a very, very hard place.
#1
(specifically problems with geany)

For my programming assignment, I have to implement classes as .h files and the definitions of the functions in their respective interfaces as .cpp files. The problem is that, the text editor I use, geany, decides to read my .h files as C code, and classes don't exist in C, so I get error messages at literally everything (the worst one is that string is not a data type, funnnnn). I can't test my code because of this, so I literally cannot do anything but blindly code and hope that it will all work out (I have literally spend two days straight trying to bypass this issue).

My TA's instructions to solve this issue was (it was a common issue):
 Spoiler

Long term solution did absolutely nothing for me, and the short term solution is undone the moment I restart geany. I cannot do anything, and I feel that I am unable to properly do this assignment simply because geany is a massive douche. To make matters worse, my building is on lockdown for hours (and still going), so I'm pretty frustrated right now (had to walk to a computer lab in pouring rain). How do I solve this problem?

General rundown of how my stuff looks:
iostream in all .h files
string in all .h files
.h files for classes that have other classes
corresponding .h files for each .cpp file (e.x user.cpp has #include "user.h"
inclusion guards in all of my .h files)

If requested, I can post what I have so far.
Reply
#2
For the filetype_extensions.conf, you COULD try just deleting the line, however I have no idea what kind of effects, adverse or otherwise, it would have. I've never used geany.

As for the part about string not being a data type, if you haven't set "using namespace std;", you will have to reference string as "std:Confusedtring". I don't know if you have done this or not, but those are the two things I can think of at this time.

It has been a long time since I've worked in C++ (I should do something about that), so I cannot really think of much else at this time.
Reply
#3
Does the filetype_extensions.conf file have a C++ line? Try adding *.h to that (in addition to commenting out the C line).

If that doesn't work, try changing the file names to .hpp.
Hopefully your instructor won't mind, since you're still putting the class header in a separate file from its implementation, as required.

I don't know geany at all, but some other editors get it right if you insert the following line as the first line in every .h file:
Code:
// Hey, geany, this is a C++ file
(The exact text doesn't matter, what matters is that it's a C++ comment. C only allows /* */ style comments)

Good luck.
Reply
#4
Are you forced to use "Geany"?

[MENTION=4093]SaptaZapta[/MENTION]; Huh? As of C99 (Which is 13 years old now) you can have single line comments in C.
Reply
#5
Locked Wrote:Are you forced to use "Geany"?

[MENTION=4093]SaptaZapta[/MENTION]; Huh? As of C99 (Which is 13 years old now) you can have single line comments in C.

Sorry to misguide (haven't used C in longer than that, unfortunately), but as of 8 years ago or so, that type of comment still worked on some emacs flavors and at least one Unix IDE whose name I forget but used file logic. I admit it's a rather desperate solution, that's why I put it third.
Reply
#6
Locked Wrote:Are you forced to use "Geany"?

[MENTION=4093]SaptaZapta[/MENTION]; Huh? As of C99 (Which is 13 years old now) you can have single line comments in C.

Yep.

I don't want to delete anything in filetype because I might end up deleting something that shouldn't be deleted.
Reply
#7
Imagine Wrote:Yep.

I don't want to delete anything in filetype because I might end up deleting something that shouldn't be deleted.

Could always back it up, or just copy it into notepad and see what happens.
Reply
#8
Did you restart after editing conf file?
Reply
#9
happylight Wrote:Did you restart after editing conf file?

Restarted geany + VM multiple times. Nothing works.
Reply
#10
Try renaming your header files to have the extension ".hpp".

I use Geany primarily on Arch, though, and I haven't encountered this issue when editing C++ header files..
Reply
#11
Problem was that I suck at keeping track at header info.
Reply
#12
This isn't really a C++ problem, it's just a problem with your environment. Does it compile and build, or is it just a text editor?
Reply
#13
Dusk Wrote:This isn't really a C++ problem, it's just a problem with your environment. Does it compile and build, or is it just a text editor?

The problem was that I just suck at remembering all the headers I needed and where to put them.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)