Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Slash
Apr 7, 2011

Shouldn't you let the database itself handle the primary key creation? Using for example an auto-incremented identity column.

When you create a record the database will automatically create the key for you. You can use DBCC commands in SQL Server to find the current identity value(DBCC CHECKIDENT "tablename") if you for some reason you need the ID before creating the record.

Reference material: http://www.w3schools.com/sql/sql_autoincrement.asp

Adbot
ADBOT LOVES YOU

Slash
Apr 7, 2011

e: quote is not edit.

Slash
Apr 7, 2011

Ciaphas posted:

Depends on if you define "willingly" as "because I like my job otherwise".

kill me

Yep we use it too, although we're currently in the process of moving off of Solaris and onto Linux, so hopefully not for much longer.

Slash
Apr 7, 2011

xgalaxy posted:

QTCreator is an abomination and I don't know why anyone recommends it. CLion is great if you like having a cross platform IDE with great refactoring support for C++. However it is a huge disappointment in the debugging department because it just uses GDB -- which I don't know why I expected different. If I need to debug something nothing beats Visual Studio.

Care to elaborate on what is wrong with QtCreator? We've been using it to develop cross platform qt/c++ code on Windows and Linux and I've not had any problems with it. The keyboard navigation shortcuts and auto complete have been spot on. Debugging on windows with it can be a bit sketchy though.

Slash
Apr 7, 2011

ani47 posted:

If you're getting vs get the community edition - it's the free version of the pro version. It has everything that the pro version has including plugins which the express version don't.

vs community


I find they all have the capability of producing head scratching error messages. At work we use clang & vs - so when I get a confusing error message I just try compiling in the other compiler to see if it makes more sense.

g++ has more descriptive/less obtuse error messages that VS. VS error messages can be incredibly opaque sometimes and require googling. Luckily stack overflow usually has the answer.

Slash
Apr 7, 2011

MrBadidea posted:

I want the poo poo out of this for Visual Studio. How many limbs is this going to cost me???

Do you mean the mouse over tooltip variable values? It does that already, doesn't work so well for stl types though.

Slash
Apr 7, 2011

MrBadidea posted:

No, the inline variable view; the not-quite-a-comment poo poo appended to a bunch of the lines in that screenshot. It makes way more sense to me than the watch window, and it kinda sits better with how I headspace code I'm working on.

I see what you mean. Yes that would be very handy.

Slash
Apr 7, 2011

I'm surprised no one has attempted to do this as a one-liner yet.

Slash
Apr 7, 2011

Ekster posted:

Yeah I'm already doing that. I was just looking for a generic data structure library for the long run, but judging from the responses the library I linked is bad. I think I'll look into it later when I know enough about data structures/algorithms so I can actually tell which libraries are bad or not myself.

How about the STL?

Slash
Apr 7, 2011

QtCreator is a pretty nifty IDE nowadays. Cross platform too so you can use the same tool on Windows and Linux.

If you use a project(.pro) file well you can even use exactly the same code on Windows and Linux. QtCreator uses qmake to turn your pro file into a compatible makefile for the platform you're building on e.g. nmake for msbuild/visualstudio and gmake on Linux. It will even generate solution files if you want to use Visual Studio IDE.

Slash
Apr 7, 2011

Hyvok posted:

Is there any way to read contents of a file to a variable (string) at compile time? I don't want to ship shaders and database schemas and stuff like that as separate files with the binary. Having them in an included file is a hassle since you need to escape all newlines and quotation marks and such. I could always write some script and/or cmake thing that mangles raw data contained in a file to a .h file but that is a bit too complicated.

When I've wanted to include data at compile time I've added a build step which runs a python script to generate a header file with the compile time data i wanted, then include that header file.

Slash
Apr 7, 2011

b0lt posted:

Or the world's worst sampling profiler: attaching gdb and randomly ctrl-c'ing to check the status of everything. (this also has the side benefit of helping make sure you properly handle EINTR)

This is how I do profiling, (attach debugger, randomly hit pause in the debugger and see where you are in the call stack), law of probability says you'll likely hit the offending method that's taking up all the time.

Slash
Apr 7, 2011

leper khan posted:

Why not spend less time and get more information by opening a single window?

Ok not profiling, more figuring out why the application is suddenly going slow for no apparent reason.

Slash
Apr 7, 2011

F_Shit_Fitzgerald posted:

I’m writing a hangman program to practice using std::map (this is not a class assignment). I’ve created a std::map<string, int> where string is a letter in the alphabet, and int is the number of times it appears in a puzzle.

My problem is coming from reading an external data file into the program. I want to read a text file of twenty-six numbers, each representing how many times the letter appears. The appropriate values will be filled in as they are read from the external file. But I can’t figure out how to instruct the program to insert into the value and not the key. Is there a way around this?

Simplest method is the following:
"a" is the key, 3 is the value.
code:
std::map<string, int> blah;
blah["a"] = 3;
Or there are more powerful methods here, which let you check if the object already existed in the map or insert ranges.
http://www.cplusplus.com/reference/map/map/insert/

Adbot
ADBOT LOVES YOU

Slash
Apr 7, 2011

hackbunny posted:

Since I don't see a Windows thread, I guess I'll ask here

What framework would you use to make a Windows UI? Outside of Qt, which my coworker has no experience in, and the first to say "HTML" will be shot in the face

Tell your cow-orker to learn Qt? Plenty of resources around.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply