Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 522 523 [524] 525 526 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 908041 times)

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7845 on: September 16, 2015, 04:15:26 pm »

I'm glad I finally gave Notepad++ a try. It's like IDLE, except for many more languages than Python.

While learning C++, I'm quickly discovering that IDEs are something I should worry about after I've gained much, much, much more experience. A lot of the auto-generated files that are so helpful when, say, creating a GUI in Swing with Netbeans, just get in the way and muddy the water when learning C++.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7846 on: September 16, 2015, 04:51:15 pm »

Idk, VS has helped me a lot in actually figuring out why my code isn't compiling instead of throwing incomprehensible errors (I know there's a reason the compiler itself can't just say "missing semicolon")
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7847 on: September 16, 2015, 04:55:46 pm »

I dunno, g++ is giving me pretty standard if long-winded error messages. They usually look like:

Code: [Select]
butts.h:7:18: error: expected ';' after class definition
dickbutt.cpp in function main():
dickbutt.cpp:23:14: no class named 'myButt'

A lot of times, I find that an IDE just copies what the compiler is saying anyway, with some added stuff like the time it took to compile, the value returned by main(), stuff like that. I've never used VS though.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7848 on: September 16, 2015, 05:27:05 pm »

I dunno, g++ is giving me pretty standard if long-winded error messages. They usually look like:

Code: [Select]
butts.h:7:18: error: expected ';' after class definition
dickbutt.cpp in function main():
dickbutt.cpp:23:14: no class named 'myButt'

A lot of times, I find that an IDE just copies what the compiler is saying anyway, with some added stuff like the time it took to compile, the value returned by main(), stuff like that. I've never used VS though.
You're using the wrong language:
http://smbc-comics.com/index.php?db=comics&id=1169#comic

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7849 on: September 16, 2015, 05:39:19 pm »

Yeah, I start naming things silly things when I'm starting to get salty with a language :P
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7850 on: September 16, 2015, 07:52:38 pm »

VS's error reporting is just what the compiler gives, as far as I know.  So, yeah, if you're using templates or the standard library's templates especially, errors can quickly becoming entirely incomprehensible.  Today I was working with std::unordered_set and needed to add the ability to insert a custom class into it.  You just have to create a specialization of std::hash for your class and make sure it has an equality operator, but that's it.

Not having those led to more errors than would fit in the default maximum scroll distance on my terminal window.  It took 8 lines of code to fix I think, and all it had to tell me is that I needed a specialization of std::hash.

Of course, getting the compiler to understand that is hard enough, so that's why it hasn't been done yet.
Logged
Through pain, I find wisdom.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #7851 on: September 17, 2015, 12:01:02 am »

I hate Apache. And PHP. WSGI, you too. >:l

Also Sublime Text 2 for not translating tabs into spaces for one specific file only, despite doing it fine for this other file of the same extension...

Also mac, because mac.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7852 on: September 17, 2015, 05:27:55 am »

VS's error reporting is just what the compiler gives, as far as I know.  So, yeah, if you're using templates or the standard library's templates especially, errors can quickly becoming entirely incomprehensible.  Today I was working with std::unordered_set and needed to add the ability to insert a custom class into it.  You just have to create a specialization of std::hash for your class and make sure it has an equality operator, but that's it.

Not having those led to more errors than would fit in the default maximum scroll distance on my terminal window.  It took 8 lines of code to fix I think, and all it had to tell me is that I needed a specialization of std::hash.

Of course, getting the compiler to understand that is hard enough, so that's why it hasn't been done yet.

Ahh... If you're adding your own stuff to a large library, then I see. I was getting some pretty huge error messages while trying to use std::string with PDCurses. I'm not sure what the conflict is, but maybe one day I'll sit down and figure it out.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7853 on: September 17, 2015, 07:39:14 am »

Off the top of my head I'm guessing you probably need to convert the std::string into a c-string for the PDCurses library, although I've never used it.  If that's the case, usually you can just call .c_str() on the string when passing it to something.  That's just a stab in the dark though.

Anyway, I find it amusing that there are tools that exist specifically to make error messages from the C++ standard library easier to read.  Honestly, having the compiler remove the namespaces from the errors unless there was ambiguity would help a lot to shorten it.  If you don't have an unordered_set class in your code, then there's really no reason for it to prefix that with std:: everywhere.  Same with strings, vectors, maps and so on.

I guess nothing can really help the fact that a templated variable can invoke a ton of template expansions though.
Logged
Through pain, I find wisdom.

Dutrius

  • Bay Watcher
  • No longer extremely unavailable!
    • View Profile
    • Arcanus Technica
Re: if self.isCoder(): post() #Programming Thread
« Reply #7854 on: September 17, 2015, 08:09:31 am »

I bought a C# style guide book the other day. I am currently going through my code, standardizing the naming of things.
Logged
No longer extremely unavailable!
Sig text
ArcTech: Incursus. On hold indefinitely.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7855 on: September 17, 2015, 08:45:41 am »

Off the top of my head I'm guessing you probably need to convert the std::string into a c-string for the PDCurses library, although I've never used it.  If that's the case, usually you can just call .c_str() on the string when passing it to something.  That's just a stab in the dark though.

All of the PDCurses functions take char* rather than string, yes, but this happens even in a blank file with just the #includes. Here's the full error:

Code: [Select]
In file included from c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/string:42:0,
                 from hellonpp.cpp:2:

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:115:67: error: macro "move" passed 3 arguments, but takes just 2

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:182:65: error: macro "move" passed 3 arguments, but takes just 2

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:268:62: error: macro "move" passed 3 arguments, but takes just 2

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:339:62: error: macro "move" passed 3 arguments, but takes just 2

In file included from c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/string:54:0,
                 from hellonpp.cpp:2:

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/basic_string.h:365:35: error: macro "move" passed 3 arguments, but takes just 2

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/basic_string.h:1359:54: error: macro "erase" passed 2 arguments, but takes just 0

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/basic_string.h:1375:32: error: macro "erase" passed 1 arguments, but takes just 0

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/basic_string.h:1395:46: error: macro "erase" passed 2 arguments, but takes just 0

In file included from c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/string:55:0,
                 from hellonpp.cpp:2:

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/basic_string.tcc:393:45: error: macro "erase" passed 2 arguments, but takes just 0

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/basic_string.tcc:649:17: error: macro "erase" passed 1 arguments, but takes just 0

In file included from c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/string:42:0,
                 from hellonpp.cpp:2:

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:184:7: error: expected primary-expression before 'return'

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:184:7: error: expected '}' before 'return'

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:184:7: error: expected ';' before 'return'

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:189:14: error: expected nested-name-specifier before 'char_traits'

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:189:25: error: expected initializer before '<' token

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:199:14: error: expected nested-name-specifier before 'char_traits'

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:199:25: error: expected initializer before '<' token

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/char_traits.h:209:1: error: expected declaration before '}' token

I discovered something else though... This only occurs if you include curses and THEN string. If you include string before including curses, then it works fine and dandy. My theory is that if std::string isn't present, PDCurses by itself will overwrite some symbols that std::string normally uses. However, if std::string is included, it won't define those symbols, assuming you mean to use the std::string ones. Hence why it works if you include string then curses, but not if you include curses and then string.
« Last Edit: September 17, 2015, 08:52:10 am by itisnotlogical »
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7856 on: September 17, 2015, 07:52:02 pm »

So I have a problem in my code where I need to display a table to show information.

I have so far Bank of Apples and then other info such as interest rates. But I can't seem make a new set of lines without making just one huge line.
                  -----------------

EX: Bank of Apples   Interest rates
     ----------------     ---------------

Instead of

Bank of Apples  Interest rates
----------------------------------

I'm using setw and setfiller ('-') to do this btw. This is for C++ btw.

EDIT: This is my code so far:

Spoiler (click to show/hide)

Some of it is exed out by // but that's because I was playing around to see what works.
« Last Edit: September 17, 2015, 08:03:22 pm by 3man75 »
Logged

Bauglir

  • Bay Watcher
  • Let us make Good
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7857 on: September 17, 2015, 08:23:27 pm »

Well, I don't know how to help you off the top of my head. However, generally when you want to display a table, your options are to precalculate it and then fill it in row by row, or else to use some of the funky ANSI escape sequences that move the cursor around to do things cell by cell.

Although if anybody knows of a C++ library for doing command line display table output, that'd be great. I'm sure somebody's bothered to put something together.
Logged
In the days when Sussman was a novice, Minsky once came to him as he sat hacking at the PDP-6.
“What are you doing?”, asked Minsky. “I am training a randomly wired neural net to play Tic-Tac-Toe” Sussman replied. “Why is the net wired randomly?”, asked Minsky. “I do not want it to have any preconceptions of how to play”, Sussman said.
Minsky then shut his eyes. “Why do you close your eyes?”, Sussman asked his teacher.
“So that the room will be empty.”
At that moment, Sussman was enlightened.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7858 on: September 17, 2015, 08:42:42 pm »

I discovered something else though... This only occurs if you include curses and THEN string. If you include string before including curses, then it works fine and dandy. My theory is that if std::string isn't present, PDCurses by itself will overwrite some symbols that std::string normally uses. However, if std::string is included, it won't define those symbols, assuming you mean to use the std::string ones. Hence why it works if you include string then curses, but not if you include curses and then string.

Very likely so, and worrisome.  I'd be concerned that it won't run even if it compiles, or may behave unpredictably.

I'm guessing that PDCurses was really only intended to be used with C, so you may have to write wrappers to any PDCurses code that's compiled as strict C code and then linked to the rest of your program.
Logged
Through pain, I find wisdom.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7859 on: September 17, 2015, 08:45:08 pm »

Well, I'm not using curses for anything serious (yet). I was just going to use it as the display for a Game of Life implementation, to start actually writing something in C++.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.
Pages: 1 ... 522 523 [524] 525 526 ... 796