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
22 Eargesplitten
Oct 10, 2010



Star War Sex Parrot posted:

I don't really find myself mixing C and C++ libraries very much, but I think if you want to use the C STL in C++ you should to include it as <cstdlib>, not <stdlib.h>

Try that first, I guess.

edit: I don't use MSVS so I had to look up what stdafx.h was. Huh.

So stdfax isn't necessary? I never saw it when I used VS 2008.

Are .h files necessarily C files? Should I not be creating .h files of my own, is there some other format that would be better?

Adbot
ADBOT LOVES YOU

sarehu
Apr 20, 2007

(call/cc call/cc)

22 Eargesplitten posted:

Are .h files necessarily C files? Should I not be creating .h files of my own, is there some other format that would be better?

C++ header files are often named with .h, sometimes with .hpp. Using .h is traditional and fine, even though you could sperg out and argue .hpp is "better" (which I would do, personally). (I mean, if you open a .hpp, your editor knows how to syntax highlight it!)

(And in general, a multi-file C++ project should definitely have header files.)

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
stdafx is your project's precompiled header, you stick stuff in there that you're going to want included in every single file.

.h is C or C++; most standard headers just leave off the extension. In the end all an include is doing is just text substitution so it doesn't matter what you name them (they don't have a "format")

I've heard good things about Qt but I've never actually done any work in it myself. It's probably better to learn Qt than MFC though.

nielsm
Jun 1, 2009



22 Eargesplitten posted:

So stdfax isn't necessary? I never saw it when I used VS 2008.

Precompiled headers isn't required no, but Microsoft's C++ project file generator likes to set it up by default, and it's slightly annoying to remove again afterwards. I think they name the precompiled header file "stdafx" because it's supposed to just contain standard library headers, but not sure.

pseudorandom name
May 6, 2007

They named it stdafx.h because pre-release MFC was called AFX and precompiled headers were added to make MFC application compile times not be completely terrible.

b0lt
Apr 29, 2005

Star War Sex Parrot posted:

I don't really find myself mixing C and C++ libraries very much, but I think if you want to use the C STL in C++ you should to include it as <cstdlib>, not <stdlib.h>

Try that first, I guess.

edit: I don't use MSVS so I had to look up what stdafx.h was. Huh.

Both of the stdfoo.h and cstdfoo headers are required to exist in C++, the only difference is that cstdfoo is required to export globals in the std namespace, and stdfoo.h is required to export them in the global namespace. They can also optionally export things in the other namespace (IIRC, libc++ and libstdc++ both have cstdfoo exporting in both std and ::)

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today
Qt is kind of worryingly heavyweight but it works pretty well and is easy enough to use in general. No idea what specific quirks there might be on windows, let alone when trying to use VS.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

Dessert Rose posted:

I've heard good things about Qt but I've never actually done any work in it myself. It's probably better to learn Qt than MFC though.

It's good! really good! Can't really comment on the graphics/UI part because I'm using it on a platform (BlackBerry Native) which has its own UI framework (Cascades) specifically incompatible with Qt's standard UI, but the whole QObject framework is very powerful and its message-passing makes multithreading and structuring your application into independent components painless. Its various container/data classes are pretty good too, as they're all based on shared copy-on-write storage and they can be copied in O(1) time (very important in pre-rvalue reference C++); the containers are STL-compliant too. Yes, it has its own project file format and several mandatory non-standard build tools, and I never used it in Visual Studio, so I can't comment on how well it integrates with it, but code-wise it's a solid choice

MFC is the best choice for Windows and has the best integration with Visual Studio (Visual Studio and MFC are virtually designed for each other), but it's Windows-only

hackbunny fucked around with this message at 14:29 on Nov 7, 2015

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

hackbunny posted:

MFC is the best choice for Windows and has the best integration with Visual Studio (Visual Studio and MFC are virtually designed for each other), but it's Windows-only
Counterpoint: MFC is loving awful and it's less painful to just use the old WINAPI C API for Windows stuff than to let MFC force your project into the hideous macro-ridden shape it prefers.

Meat Beat Agent
Aug 5, 2007

felonious assault with a sproinging boner
There are Qt 4 and Qt 5 add-ins for VS that automatically handle the extra tooling. It generally works pretty well (I use it at my job where all of the Windows builds of our Qt applications are built with VS2013; I generally prefer MinGW otherwise) and you get the added benefit of not having to torture yourself with Windows-specific frameworks.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
Also, and I guess this is getting way too complex for OP, you can use CMake to set up your project. It has support for Qt and will automatically generate Visual Studio .vcxproj and .sln files that invoke all the right Qt tools during build.

csammis
Aug 26, 2003

Mental Institution

roomforthetuna posted:

Counterpoint: MFC is loving awful and it's less painful to just use the old WINAPI C API for Windows stuff than to let MFC force your project into the hideous macro-ridden shape it prefers.

Counter-counter point: all StashAugustine is trying to do is jam together a simple UI for a class project so presumably he/she doesn't care about the hand-waving generated macros aspects of MFC. Visual Studio makes it relatively painless to make a new MFC project and get you going in the dialog designer. I'm guessing that learning the Win32 windows API from RegisterClass/Ex to CreateWindow/Ex and all that good poo poo is not on the class syllabus.

Xarn
Jun 26, 2015
What is a nice and sane C++ concurrency library? This means higher level than <thread>, <mutex> et al. and less macroy than OpenMP pragmas.

Bonus points if it runs on Windows as well as on Linux.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

csammis posted:

Counter-counter point: all StashAugustine is trying to do is jam together a simple UI for a class project so presumably he/she doesn't care about the hand-waving generated macros aspects of MFC. Visual Studio makes it relatively painless to make a new MFC project and get you going in the dialog designer. I'm guessing that learning the Win32 windows API from RegisterClass/Ex to CreateWindow/Ex and all that good poo poo is not on the class syllabus.
Maybe MFC is less awful now than when I used it, but back then it was more painful to use MFC even *with* the wizards generating your templates than it would have been to just copy and paste the Win32 boilerplate from the documentation and work from there.

And I say this as someone who learned the MFC way first, so it's not like I was just clinging to what I was used to. Switching to WinApi was a relief.

Though to be fair, it might be partly my preference for drop-down menus that you can't snap off your program and put somewhere else. WinApi menus behave old school by default, MFC menus you have to dig through documentation and find out how to turn off all the sparkly modern bullshit if you don't want it.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
Why would I be getting an internal compiler error on a piece of code I've compiled with the exact same compiler hundreds of times before? I'm using g++ 4.9.something on MinGW64. On my current project I'm suddenly getting errors on an include of <vector> that seems to refer me to their implementation of initialiser lists.

It's telling me to file a bug report to the mingw team, but I'm not sure how it can suddenly become bugged from one day to the next. My code base is literally the same as I succesfully compiled on the same system just two days ago.

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

Xarn posted:

What is a nice and sane C++ concurrency library? This means higher level than <thread>, <mutex> et al. and less macroy than OpenMP pragmas.

Bonus points if it runs on Windows as well as on Linux.
What exactly do you want it to do for you?

Joda posted:

Why would I be getting an internal compiler error on a piece of code I've compiled with the exact same compiler hundreds of times before? I'm using g++ 4.9.something on MinGW64. On my current project I'm suddenly getting errors on an include of <vector> that seems to refer me to their implementation of initialiser lists.

It's telling me to file a bug report to the mingw team, but I'm not sure how it can suddenly become bugged from one day to the next. My code base is literally the same as I succesfully compiled on the same system just two days ago.
Maybe something clobbered your environment variables?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Xarn posted:

What is a nice and sane C++ concurrency library? This means higher level than <thread>, <mutex> et al. and less macroy than OpenMP pragmas.

Bonus points if it runs on Windows as well as on Linux.

Maybe check out Intel TBB? It's not to everyone's tastes, but I recall being generally happy with it.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe

Ralith posted:

Maybe something clobbered your environment variables?

Far as I can tell they point to the versions of g++ and gcc they always have. I did try and redirect them to a fresh mingw download and now it works though, so I dunno. I might have accidentally edited the C++ standard libraries or something.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Sagacity posted:

Also, and I guess this is getting way too complex for OP, you can use CMake to set up your project. It has support for Qt and will automatically generate Visual Studio .vcxproj and .sln files that invoke all the right Qt tools during build.

Honestly CMake is great, it took me maybe an hour to get it working, and it's definitely worth spending that hour learning CMake instead of makefiles.

Builds look much nicer, you can autogenerate Xcode, VS and I assume Eclipse project files, the format isn't nearly as brain damaged...

Much like learning Qt and C++ in the first place, learning CMake will allow you to apply your knowledge across all platforms instead of tying yourself to one or two.

Doctor w-rw-rw-
Jun 24, 2008

Dessert Rose posted:

Honestly CMake is great, it took me maybe an hour to get it working, and it's definitely worth spending that hour learning CMake instead of makefiles.

Builds look much nicer, you can autogenerate Xcode, VS and I assume Eclipse project files, the format isn't nearly as brain damaged...

Much like learning Qt and C++ in the first place, learning CMake will allow you to apply your knowledge across all platforms instead of tying yourself to one or two.

I favor the "Eclipse CDT4 - Ninja" generator, even on OS X – I find the Xcode generator is pretty much trash. Perhaps it's because Xcode's native build system is..."unique".

CMake seems pretty arcane and obtuse at times, but even so, the developer experience with it is well ahead of everything else I've tried for C++ (aside from developing for Apple platforms on a Mac).

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today
Build system chat:

I ultimately just gave up and hand-rolled a python script to produce ninja files. Maybe Bazel will become good someday.

Tup's pretty neat in a gimmicky kind of way, but it relies heavily on magic and is basically just one guy and he makes some weird design decisions.

ullerrm
Dec 31, 2012

Oh, the network slogan is true -- "watch FOX and be damned for all eternity!"

Could you go into more detail on what Bazel's lacking?

(Half of my code at work builds in blaze, so I've been considering it for my home projects. ATM, I'm using jam.)

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today
It doesn't play well with dependencies from the host system (because you can't sanely call pkg-config or similar) and as far as I can tell it's not realistic to vendor all your dependencies the way Google does with Blaze (because they'll have non-Bazel build systems and you really don't want to maintain your own build system of third party code). This leaves you with a build system that's only useful for projects without significant dependencies, and for projects without significant dependencies you can probably get away with a simple shell script anyway.

It's also really awkward to use anything but the exact toolchain configuration that some engineer at Google assumed everybody would always want, because it relies on these great big sparsely-documented toolchain definition files. For example, I like to use clang 3.7 with libc++ on linux, but by default Bazel will have none of that. In general, doing anything off the beaten path (say, calling out to custom tools) rapidly lands you in territory with little if any documentation. Note also that the beaten path is almost entirely Java-related.

My understanding is that they're working on fixing the first issue, at least, so maybe someday it'll be the cmake killer we all want, but it's not there yet and Google might just decide to abandon the effort before it gets close.

Even ignoring all those issues, though, it's still a huge enterprisey java project with bad startup times and tons of its own dependencies and so forth. Not really what I want in a fundamental build tool.

Ralith fucked around with this message at 09:13 on Nov 10, 2015

FamDav
Mar 29, 2008

Ralith posted:

Even ignoring all those issues, though, it's still a huge enterprisey java project with bad startup times and tons of its own dependencies and so forth. Not really what I want in a fundamental build tool.

bazel and other heterogenous build systems are beastly because they solve problems that you don't really encounter in personal development. google at least has the simplicity of only building HEAD of a single omni-repository.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Bazel probably won't ever become useful for things where you don't completely control the build environment. The set of problems that portable build systems try to solve and the set of problems that things like Bazel try to solve are almost entirely disjoint.

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today
It's worth noting that completely controlling the build environment is generally a great idea, especially for larger projects. It's just that right now, say, Nix (or even just a pile of shell scripts) does a better job of that than Bazel for anyone who isn't Google.

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line
I'm trying to implement a program using restricted transactional memory, but I'm consistently getting an 'illegal instruction (core dumped)' error when running any program using the _xbegin() call. I'm working off've the stuff here, using g++ 4.9, and compiling like so:

code:
g++ -mrtm -std=c++11 -o "rtest" rtm_test.cpp
with rtm_test.cpp:

code:
#include <immintrin.h>

int main(int argc, char** argv){
	int result = 0;
	int status;
	if((status = _xbegin ()) == _XBEGIN_STARTED) {
		result = 1;
	_xend();
	}
	else{
		result = 2;
	}
	return result;
}
I'm getting this error on different systems, so I'm not thinking it's a problem with my specific hardware, but I'm unsure where I'm going wrong here. Any ideas?

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today
What CPUs are you testing on?

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line
my local machine is:

Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz

I'm also testing on some servers my school provides which have:

AMD Opteron(tm) Processor 6172

Xarn
Jun 26, 2015

Subjunctive posted:

Maybe check out Intel TBB? It's not to everyone's tastes, but I recall being generally happy with it.

TBB is what I definitely plan on checking out, but I was looking for alternatives.

Ralith posted:

What exactly do you want it to do for you?

Give a reasonably simple task oriented interface... IE being able to chain tasks, not having to explicitly manage threads for simple async stuff.

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

JawKnee posted:

my local machine is:

Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz

I'm also testing on some servers my school provides which have:

AMD Opteron(tm) Processor 6172
Neither of those CPUs implement the instructions you're trying to use.

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line
well poo poo. Not sure where my professor expects me to test this stuff then.

ullerrm
Dec 31, 2012

Oh, the network slogan is true -- "watch FOX and be damned for all eternity!"

Neither of those CPUs support the TSX instructions. You need to use CPUID to detect if they're available on your CPU before you try to call them.

e: ^^^ You need a machine with one of the new Skylake processors -- Core 6xxx. Depending on stepping, some of the Core i5-5xxx models may have it.

ullerrm fucked around with this message at 20:45 on Nov 10, 2015

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Ralith posted:

It's worth noting that completely controlling the build environment is generally a great idea, especially for larger projects. It's just that right now, say, Nix (or even just a pile of shell scripts) does a better job of that than Bazel for anyone who isn't Google.

For purely internal software, absolutely. For anything intended to be built and run by third parties on their machines it's not really an option.

22 Eargesplitten
Oct 10, 2010



With Visual Studio's weird file specifying a file to hold header imports thing, is there a recommended compiler other than VS? From the sound of it, Microsoft is encouraging some weird stuff that nobody else does with that file.

KaneTW
Dec 2, 2011

JawKnee posted:

well poo poo. Not sure where my professor expects me to test this stuff then.


Support for TSX emulation is provided as part of the Intel Software Development Emulator.[11] There is also experimental support for TSX emulation in a QEMU fork.[12]

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
The only thing remotely unusual about visual studio's use of a precompiled prefix header is that it's set up by default in new projects. It's trivial to turn off and all mainstream compilers support it.

Null Pointer
May 20, 2004

Oh no!

Plorkyeran posted:

The only thing remotely unusual about visual studio's use of a precompiled prefix header is that it's set up by default in new projects. It's trivial to turn off and all mainstream compilers support it.

MSPCH is a strange beast, but the least unusual thing about it is that it exists.

The most unusual part? Probably #pragma hdrstop.

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

Plorkyeran posted:

For purely internal software, absolutely. For anything intended to be built and run by third parties on their machines it's not really an option.
To the contrary, it typically makes distribution to third parties far less painful (up to compatibility of glibc/kernel/etc), especially if you target windows. Making it convenient for third parties to build is another matter, and is of course what good tooling is supposed to address. For example, Nix makes it really easy.

Adbot
ADBOT LOVES YOU

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Speaking of build stuff, why is it that the Unix-like solution to static libraries is still to throw all of the .o files into an archive instead of doing something like running it through the linker to generate a new ELF file and nuke all of the ODR redundancies?

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