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
rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Clang-on-Windows is probably not a supported configuration for Boost. You could try to push those changes into Boost (although they'll probably ask you to test on a newer release / trunk), but yeah, even if you get that to work, you are very likely to run into interop problems if your other libraries actually use C++ interfaces. Sorry; it's something the community's actively working on, but it's not done yet by any means.

Adbot
ADBOT LOVES YOU

ZombieApostate
Mar 13, 2011
Sorry, I didn't read your post.

I'm too busy replying to what I wish you said

:allears:
I found the first three posts on that bug report in some mailing list thing, but it didn't have the rest of it and the actually bug report never showed up. Why you hate me google? Anyway, that's kind of what I figured. It was an interesting experiment, but back to what I was doing before. Thanks :buddy:

Volte
Oct 4, 2004

woosh woosh
I'm trying to get my CMake project that uses clang and C++11 (libc++) to work with Google Test but I keep getting errors of the following sort during linking:

quote:

Undefined symbols for architecture x86_64:
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::find(char const*, unsigned long, unsigned long) const", referenced from:
[20 pages of errors]
My guess is that it's there are conflicting standard libraries but I am building Google Test with the same flags (-stdlib=libc++ -std=c++11) as my project (verified through make VERBOSE=1), enabling GTEST_USE_OWN_TR1_TUPLE (apparently this is no longer needed on trunk), and linking them using the FindGTest module (with the GTEST_ROOT variable set on the command line) that comes with CMake 2.8. I'd rather avoid keeping gtest in my repository and building it as part of the same build process.

Volte fucked around with this message at 01:51 on May 4, 2013

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Obvious reason would be if -stdlib=libc++ is only getting passed to the compiler and not to the linker.

Volte
Oct 4, 2004

woosh woosh

Plorkyeran posted:

Obvious reason would be if -stdlib=libc++ is only getting passed to the compiler and not to the linker.
Whoops, that was it. I was setting the wrong linker flags variable in CMake. Thanks.

xgalaxy
Jan 27, 2004
i write code
Why does using move semantics have to be so cumbersome. So I have to create a move constructor AND mark it noexcept in order for std::vector to actually move it instead of copy it. Would I still have to mark the constructor noexcept if I was able to disable exceptions?

Bonfire Lit
Jul 9, 2008

If you're one of the sinners who caused this please unfriend me now.

C++ with exceptions disabled is no longer (standard) C++, so it really depends on your compiler. If I had to take a guess, I'd assume that you'd still have to mark it noexcept, because the noexcept operator probably doesn't take into account that exceptions are disabled.

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE
I'm working in Thrust, is there a nice way to do a transform and reduce some result in a single step while still keeping the transformed output? It could be done with a transform_iterator plus some kind of a copy-accumulate set operation. I don't know what that would be though.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Is there something in Boost for iterating compound containers? An example of such a container would be a map of strings to vectors of something else. I was hoping there was a way I could set up an iterator that would move on to the next vector in the map as soon as it exhausted all elements in the prior mapped vector. Right now I'm tracking two iterators, and that's generally fine, but I got that sense that implies there's a better solution out there.

That Turkey Story
Mar 30, 2003

Rocko Bonaparte posted:

Is there something in Boost for iterating compound containers? An example of such a container would be a map of strings to vectors of something else. I was hoping there was a way I could set up an iterator that would move on to the next vector in the map as soon as it exhausted all elements in the prior mapped vector. Right now I'm tracking two iterators, and that's generally fine, but I got that sense that implies there's a better solution out there.

I don't think there's anything directly for this, but you could make one. To be honest, though, that has its own problems unless you want to sink some time into it. Matt Austern has a paper about iterators like these if you're interested.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


loving goddamned hell, I hate Sun Studio, it's IDE and compiler both. :mad:

I'm not familiar, short of learning my way around xemacs/gvim, are there any traditional IDEs that get a lot of use on UNIX systems (preferably that support both Intel and SPARC processors)? I'm seeing Eclipse and Netbeans out there but with Sun Studio's IDE based on those I'd rather make a clean break if I can, and I don't know what the Visual Studio-style gold standard is.

(edit) To clarify it doesn't have to mirror Visual Studio or anything, I just need to be able to do some analog of right click->Go to Definition on anything in my code, syntax highlighting, etc. And yeah I know that UNIX sort of prefers not having IDEs at all but damnit I get lost fast without some IntelliSense analog.

Ciaphas fucked around with this message at 00:36 on May 9, 2013

minidracula
Dec 22, 2007

boo woo boo

Ciaphas posted:

loving goddamned hell, I hate Sun Studio, it's IDE and compiler both. :mad:

I'm not familiar, short of learning my way around xemacs/gvim, are there any traditional IDEs that get a lot of use on UNIX systems (preferably that support both Intel and SPARC processors)? I'm seeing Eclipse and Netbeans out there but with Sun Studio's IDE based on those I'd rather make a clean break if I can, and I don't know what the Visual Studio-style gold standard is.
The tradition of Unix is that it doesn't really encourage IDEs at all. That being said, for what you're looking for my suggestion is SlickEdit, but it'll cost you. It's not exactly like Visual Studio, but you can certainly configure the keybindings to be pretty VS-ish and customize what you want. It's the only IDE of its sort (again, skipping the ones you've mentioned) I've used on Unix platforms that I thought did a decent job of keeping the cross-platform IDE experience similar. I last used it on Linux circa 1998 or 1999 though. But I use (a modern version of) it today, along with VS and other things, on Windows.

Rothon
Jan 4, 2012
I've found that Sublime Text paired with the SublimeClang plugin works pretty well. It gives you pretty good intellisene, inline error output, go to definition/implementation, etc. It's not a full blown IDE experience though. There isn't support for advanced refactoring, for example.

SadBag
Jun 24, 2012

Something has gone very wrong for us to get to the point where Hot Dog is the admiral.
How would an unsigned integer be represented in memory as compared to a signed integer?

tractor fanatic
Sep 9, 2005

Pillbug
Probably exactly the same.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Rothon posted:

I've found that Sublime Text paired with the SublimeClang plugin works pretty well. It gives you pretty good intellisene, inline error output, go to definition/implementation, etc. It's not a full blown IDE experience though. There isn't support for advanced refactoring, for example.

This looks pretty much like exactly what I need, but then I realized they don't have source code or a SPARC build. I hate these machines so much :cry:

The_Franz
Aug 8, 2003

Yep, the only difference is that the compiler generates unsigned instructions for it.

SadBag
Jun 24, 2012

Something has gone very wrong for us to get to the point where Hot Dog is the admiral.
Well that's a relief. That means I bombed an interview less than I thought. :)

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
It's a question that can be answered on a lot of different levels, but probably it should be taken as an opportunity to show that you understand things like two's complement.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Two's complement signed integers is probably what the person was asking for.

... I probably asked this in here before, but has there realistically ever been another signed integer format? I'd imagine that Cray did something special, since they always did something special.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Suspicious Dish posted:

... I probably asked this in here before, but has there realistically ever been another signed integer format? I'd imagine that Cray did something special, since they always did something special.

BCD, which gets used in hobby electronics and some old-school mainframes, strongly resembles sign-and-magnitude when used in a signed manner. Sign-and-magnitude is, of course, used in the significand in modern-day IEEE floating point. I personally own some hardware designed to do signal processing which uses One's-complement for all its arithmetic, because it was desirable to have both -0 and +0 representable.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
The other common one is excess-k, which is basically unsigned numbers with the implicit understanding that the entire range is offset by some amount.

The most notable place this is used is in IEEE floating-point exponents.

SadBag
Jun 24, 2012

Something has gone very wrong for us to get to the point where Hot Dog is the admiral.

rjmccall posted:

It's a question that can be answered on a lot of different levels, but probably it should be taken as an opportunity to show that you understand things like two's complement.

Ah. I thought he was asking whether it had some special format like a floating point number. On the other hand, I did say what -1 would be represented as(correctly), so I'm hoping he was ok with it.

BirdOfPlay
Feb 19, 2012

THUNDERDOME LOSER
Good golly, I'm not only rusty at C++, but I'm lacking in some of the intricacies too.

I've never really worked on a big project, save for modding with Source in highschool, and have never started up a decently sized project myself. To make sure header files are included only once, is this best way? (Wiki calls this "include guards")
code:
#ifndef HEADERNAME
#def HEADERNAME
...
#endif
I ask because I know Source would either do that or use a #pragma once command, but I know #pragma is non-standard.

Also, I'm working with Qt framework, and I'm not sure if I'm supposed to use Qt's version's or not. One comes from string and QString, which seems to be a minor change to support Unicode-16. But the other is more of an unknown for me, do I use Qt's SQL plugins or manually add in the SQL libraries and code from there? For some info, this is a personal, "show-off" project to get me a job, so I just want whoever sees it to see that I understand SQL.

nielsm
Jun 1, 2009



That's #define, not #def.

If you want to show that you understand SQL, make sure whatever you use actually lets you write SQL, and doesn't wrap it in layers of ORM or other automatic statement generation. Apart from that, use whatever. (Qt might have some "data-aware" widgets, e.g. a table control that can automatically fetch and display rows from a table. That's not writing SQL.)

BirdOfPlay
Feb 19, 2012

THUNDERDOME LOSER

nielsm posted:

That's #define, not #def.

Quite! I kinda ran through that post without checking it. It has nothing to do with rust...

quote:

If you want to show that you understand SQL, make sure whatever you use actually lets you write SQL, and doesn't wrap it in layers of ORM or other automatic statement generation.

To be fair, that's how I'm writing my core DB accessing classes. :v: I guess my fear was someone looking at it and going "You never used a SQLite_stmt struct anywhere in this program, how can you claim to know SQLite?"

Because the people that actually will check my github will really delve into my code and cross-check my competencies. They won't go, "Oh look, here's a thing. It's big and it compiles. And this was something he did for fun." It's totally the former.

nielsm
Jun 1, 2009



Using direct APIs and using abstraction layers are different skills, but they are both valuable skills.

One argument for using any database abstraction Qt provides is that if you're picking a framework like that it's usually better to go all in, anything else can easily lead to frustrations hacking around things.

Vinterstum
Jul 30, 2003

BirdOfPlay posted:


I ask because I know Source would either do that or use a #pragma once command, but I know #pragma is non-standard.


Last time I checked, GCC (probably 4.6.x something) still had some issues with #pragma once, in particular when used in conjunction with precompiled headers. #pragma once gives you a minuscule boost in compilation speed compared to include guards (a couple of seconds on a codebase taking 10-15 minutes to compile), but not really worth it unless you know you're only targeting Visual Studio.

Then again you could always use both.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
It's still not fixed, so you should always use include guards for headers that will be installed and may be included in someone else's precompiled header, but generally projects don't put their own files in the PCH anyway so #pragma once is fine for local headers.

Hughlander
May 11, 2005

Vinterstum posted:

Last time I checked, GCC (probably 4.6.x something) still had some issues with #pragma once, in particular when used in conjunction with precompiled headers. #pragma once gives you a minuscule boost in compilation speed compared to include guards (a couple of seconds on a codebase taking 10-15 minutes to compile), but not really worth it unless you know you're only targeting Visual Studio.

Then again you could always use both.

I don't think that would be the case that it gives a speed boost in gcc:

http://gcc.gnu.org/onlinedocs/gcc-4.8.0/cpp.pdf posted:

This construct is commonly known as a wrapper #ifndef. When the header is included
again, the conditional will be false, because FILE_FOO_SEEN is defined. The preprocessor
will skip over the entire contents of the file, and the compiler will not see it twice.
CPP optimizes even further. It remembers when a header file has a wrapper ‘#ifndef’.
If a subsequent ‘#include’ specifies that header, and the macro in the ‘#ifndef’ is still
defined, it does not bother to rescan the file at all.
...
Another way to prevent a header file from being included more than once is with the
‘#pragma once’ directive. If ‘#pragma once’ is seen when scanning a header file, that file
will never be read again, no matter what.
‘#pragma once’ does not have the problems that ‘#import’ does, but it is not recognized
by all preprocessors, so you cannot rely on it in a portable program.

Previous versions of gcc even called the feature obsolete:

http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC8 posted:

The GNU C preprocessor is programmed to notice when a header file uses this particular construct and handle it efficiently. If a header file is contained entirely in a `#ifndef' conditional, then it records that fact. If a subsequent `#include' specifies the same file, and the macro in the `#ifndef' is already defined, then the file is entirely skipped, without even reading it.

There is also an explicit directive to tell the preprocessor that it need not include a file more than once. This is called `#pragma once', and was used in addition to the `#ifndef' conditional around the contents of the header file. `#pragma once' is now obsolete and should not be used at all.

The wikipedia page for pragma once even indicates that other major compilers all have special logic to recall that a file was 100% in an include guard and already included.

MrMoo
Sep 14, 2000

Notedly Google ran a huge test to see if even MSVC gained performance with #pragma once, subsequently a huge commit hit the repos ...

https://groups.google.com/a/chromium.org/forum/?fromgroups=#!topic/chromium-dev/RMcVNGjB4II

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
That thread is kind of hilarious.

quote:

You can take perfectly valid 100% correct ANSI C program, add "#pragma once" to one file and the end result will be incorrect program. That's dangerous. If you perceive it as "right" or "wrong" is another question.

Adding a line of code to a correct program can make that program incorrect, therefore being able to add lines of code is dangerous?

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

MrMoo posted:

Notedly Google ran a huge test to see if even MSVC gained performance with #pragma once, subsequently a huge commit hit the repos ...

https://groups.google.com/a/chromium.org/forum/?fromgroups=#!topic/chromium-dev/RMcVNGjB4II

Dang that's a lot of Googlers that don't understand what an include guard does and does not do! I enjoyed the cameo from yung ~LoNeWoLf~ as well.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
C++ code:
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Singly or multiply-included shared traits file depending upon circumstances.
// This allows the use of IPC serialization macros in more than one IPC message
// file.
#ifndef CHROME_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
#define CHROME_COMMON_COMMON_PARAM_TRAITS_MACROS_H_

#include "chrome/common/content_settings.h"
#include "ipc/ipc_message_macros.h"
	
IPC_ENUM_TRAITS(ContentSetting)
IPC_ENUM_TRAITS(ContentSettingsType)

#endif // CHROME_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
:q:

floWenoL
Oct 23, 2002

Otto Skorzeny posted:

Dang that's a lot of Googlers that don't understand what an include guard does and does not do! I enjoyed the cameo from yung ~LoNeWoLf~ as well.

I don't think there was a lot of misunderstanding going on, just a lot of miscommunication back and forth.

Plorkyeran
Mar 22, 2007

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

Otto Skorzeny posted:

Dang that's a lot of Googlers that don't understand what an include guard does and does not do! I enjoyed the cameo from yung ~LoNeWoLf~ as well.

It's just one guy that doesn't know what an include guard is and several people confused about why he's talking about these unrelated things.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
So, I didn't really want to trudge through the poo poo in there. Did #pragma once have any perf impact on MSVC or gcc, at all?

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Are there any situations where you WOULD want to have a header #included more than once for a given translation object? I can't think of any short of "C is old and they didn't really do it right" :(

nielsm
Jun 1, 2009



Suspicious Dish posted:

So, I didn't really want to trudge through the poo poo in there. Did #pragma once have any perf impact on MSVC or gcc, at all?

It did shave some seconds off on MSVC to use #pragma once, from what I gathered.

Ciaphas posted:

Are there any situations where you WOULD want to have a header #included more than once for a given translation object? I can't think of any short of "C is old and they didn't really do it right" :(

Well it isn't really a "header" any longer then, but it can be a kind of poor man's templating: Define some special macros, then include a file that declares stuff based on the values of those macros you defined.
Of course you wouldn't be using include guards for those files either, at least if you're sane.

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

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

Suspicious Dish posted:

So, I didn't really want to trudge through the poo poo in there. Did #pragma once have any perf impact on MSVC or gcc, at all?
10 seconds on a 30 minute build with msvc.

gcc doesn't even need the #pragma once to know it doesn't need to reread include-guarded files.

Ciaphas posted:

Are there any situations where you WOULD want to have a header #included more than once for a given translation object? I can't think of any short of "C is old and they didn't really do it right" :(

X-Macros and preprocessor loops.

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