|
I always make sure to disable the Microsoft language extensions in the project options (I believe it's in the 'Language' section). That should keep your code relatively clean so it can be ported away from Visual C++ fairly easily. It may take away 64-bit integers all together though since C++ doesn't have one in the standard.
|
# ¿ May 24, 2008 23:17 |
|
|
# ¿ May 18, 2024 08:12 |
|
I'm not sure why the compiler would discriminate against strings over any other class. And if it compiles at all, it's not the compiler's fault. If it really didn't support strings in structs for some reason, it would likely toss an error.
|
# ¿ Jul 23, 2008 23:14 |
|
I'm just dicking around with boost::spirit making a parser for a sort of JSON-ish config file format (actually inspired by .irssi/config). The grammar is defined as such:code:
code:
Volte fucked around with this message at 07:33 on Jan 24, 2009 |
# ¿ Jan 24, 2009 07:13 |
|
Thanks, I fixed that as well as changing key to bs::lexeme_d[+(bs::alnum_p | bs::punct_p)]; and it works now. No idea why it doesnt stack overflow anymore... I think maybe VS was loving me over by not recompiling the parser even though I was editing the file, so some old bug stuck around no matter what changes I made. The example document clears the parser now.
|
# ¿ Jan 24, 2009 08:30 |
|
Ugg boots posted:What do you mean spaces in attributes of tags? This isn't valid XML: <House The Name="White House" />. Unless you mean spaces in the attribute values, then that's a pretty big bug that would be missed by the TinyXML team.
|
# ¿ Jan 26, 2009 21:56 |
|
Managed C++ is a really stupid thing to use unless you're porting legacy C++ code to the .NET platform. If you are starting anew, you might as well just use C# in that case.
|
# ¿ Mar 27, 2009 23:28 |
|
Does the domain that you are testing on include numbers near the roots? It could be that the first approximation is returning denormal numbers for numbers near pi and zero and the second one is doing arithmetic on them, which would be extremely slow.
|
# ¿ Jul 25, 2011 00:17 |
|
Strangely the best free way to transparently edit remote files on Windows I've found is using Notepad++ with the bundled NppFtp plugin, which supports SFTP. I'm not a huge fan of Notepad++ in general but that particular feature is really nice, and Notepad++ is pretty lightweight.
|
# ¿ Feb 29, 2012 21:26 |
|
Pollyanna posted:Apparently it needs 10.6.8 to run and I have no idea where to find a copy of Snow Leopard God, I miss Windows.
|
# ¿ Aug 2, 2012 23:15 |
|
Netbeans and Eclipse are probably the best C++ IDEs other than Visual Studio. Eclipse CDT has been around for at least 10 years and Netbeans has supported C++ for 4-5 years also. Personally I prefer just using a nice text editor but if you really need IDE features, there's nothing wrong with Netbeans or Eclipse.
|
# ¿ Aug 6, 2012 22:06 |
|
Taylor series are generally really bad for computing elementary functions. A better method is by finding polynomials that approximate the function (something like Mathematica can compute these) to the desired precision within some small interval (like [0, pi/8] is enough for sin) and then reducing the range of the input so that it falls into that interval, and transforming the output back to the correct value through creative use of identities. One way to do exp (it's actually easier to calculate exp2 and then scale the input accordingly to do other bases: exp(x) = exp2(x * log2(e))) would be to construct an IEEE number directly, since the exponent is stored directly in the bit pattern. So if the input is x = p + q where p is the integer part and q is the fraction (so 0.0 <= q < 1.0), then you just need to compute exp2(p + q) = exp2(p) * exp2(q), where exp2(p) is constructed directly and and it's much easier to compute exp2(q) when the range is reduced like that. The hard part of doing functions like this is getting as close to last-bit accuracy as possible for the entire range of inputs, as well as correctly handling denormalized numbers, zero, infinity, and NaN. Those things were only hard in my experience in doing this because the focus was always on maximum performance (as in no branches at all) and strict accuracy requirements, so if you aren't too concerned about that, then it should not be very difficult at all.
|
# ¿ Oct 7, 2012 08:20 |
|
pow is pretty much always insanely expensive. pow(2,x) is completely unnecessary anyway since you can just insert the exponent directly into the bits of the floating point number. In fact any time that you are doing pow(C,x) with constant C, you can replace it with exp(x * log(C)) where log(C) is precomputed for a much cheaper evaluation. Chances are that pow is implemented with some combination of exp and log anyway, but computed in higher precision so it'll be even more expensive.code:
|
# ¿ Oct 30, 2012 21:29 |
|
Combat Pretzel posted:Forgot to mention, the exponents are floating point and can be negative. Sorry for the undefined behaviour. For some reason I thought that setting a union's value through one member and then accessing it with a different member was equally undefined, so I did it the simpler way. My mistake. vv
|
# ¿ Oct 31, 2012 09:49 |
|
mjau posted:The exp2 function should be available anywhere pow/exp/etc are. C99 added float and long double versions (exp2f/exp2l)
|
# ¿ Nov 2, 2012 02:59 |
|
rjmccall posted:If you're designing a library with binary stability requirements, sure, you have to be more circumspect. Of course, if it's a C library then type names aren't part of your binary interface, and if it's a C++ library then all of your public declarations should be namespaced. But designing the interface to a library with binary stability requirements is never something you should do casually.
|
# ¿ Nov 15, 2012 20:23 |
|
Hughlander posted:When interviewing people for an engineering position, I always ask them to rate themselves on a scale of 1-10 with how well they know C++. Anytime someone self-rates themselves as a 9 or 10 I ask RVO questions. I hate people who self rate at 9 or 10 and are really at like a 6 or 7.
|
# ¿ Dec 9, 2012 16:11 |
|
For one thing it may implicitly alter the calling convention of the function, since the return value can't go into a register anymore.
|
# ¿ Dec 23, 2012 01:18 |
|
String literals are guaranteed to have static storage duration, so it's perfectly safe.
|
# ¿ Dec 31, 2012 01:51 |
|
tractor fanatic posted:How do people do GUI Windows programming in C++ nowadays? Is there a favored framework, or is it a mix of MFC, ATL, QT, etc? Contrary to what others have said I would not recommend using WPF with .NET. WPF is a great idea but I've found its execution to be extremely bad and I hope you like writing XML. Granted I haven't used it extensively in about five years but the problems were fairly deeply rooted in the overall design. XAML is incredibly verbose, and lacks the ability to inline code (you can embed code literally but it's not useful or recommended) so you end up with a lot of indirection in your interface design, like having to define Converters and Commands all over the place to do the two most fundamental tasks in WPF, bind data and react to events. The time you save in having a declarative interface definition language might well be lost in the development overhead introduced by that language being god awful in almost every respect. I've never used QML and don't know if it's actually good but take a look at this example (from Wikipedia) and think about how much it would take to do it in WPF: code:
|
# ¿ Feb 4, 2013 17:49 |
|
In the context of a ray tracer, it's very useful to have Point and Vector be different classes. This lets affine transformations do the right thing automatically by cancelling the translation when transforming a Vector. You will probably also want to define a third type for Normal, since applying transformations to a normal does not affect them in the same way (see http://medialab.di.unipi.it/web/IUM/Waterloo/node45.html).
|
# ¿ Mar 9, 2013 11:36 |
|
What are you gaining by using template-level vector sizes? For 2-, 3-, and 4-vectors it makes sense since you often use them explicitly (although probably you'd be better off using separate classes, especially for matrices) but for large vectors I can't think of a scenario when you'll be explicitly using Vec<1024> rather than having your vector sizes depend on some data from a file or problem specification.
|
# ¿ Mar 9, 2013 14:51 |
|
Fair enough, although if you care about instruction-level optimization you'll probably end up specializing the member functions anyway to provide implementations for the specific small sizes. In the large case though I can't see how having it in the template argument is at all usable. Unless all your vector sizes are known at compile time (which seems unlikely in the general case) the vector class will be useless.
|
# ¿ Mar 9, 2013 21:59 |
|
the <x.h> headers have to declare them in the global namespace, and the <cx> headers have to declare them in the std namespace, but either one might declare them in both. If you want to be able to definitely for sure use them without specifying std:: then you need to use <x.h>, but I've never heard of a compiler library that doesn't import into the global namespace in the <cx> headers. As far as not polluting the global namespace, just don't include them in a header. There's not really such a thing as "polluting" the namespace in a cpp file since it doesn't bleed into any other files.
|
# ¿ Mar 11, 2013 13:12 |
|
Typedef is just like a regular variable declaration with the word typedef in front. int variable; -> typedef int typename; This particularly applies to function pointers.
|
# ¿ Apr 10, 2013 09:51 |
|
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: Volte fucked around with this message at 01:51 on May 4, 2013 |
# ¿ May 4, 2013 01:45 |
|
Plorkyeran posted:Obvious reason would be if -stdlib=libc++ is only getting passed to the compiler and not to the linker.
|
# ¿ May 4, 2013 02:26 |
|
Jewel posted:Can anyone actually tell me why functions and conditionals don't need the semicolon at the end of the brackets but classes and structs do? To answer your question, the top level constructs in a translation unit are function definitions and declarations. Function definitions don't require one but declarations could be variable declarations, function declarations, and type declarations, and no matter which one it is, it's terminated by a semicolon. A struct block is actually a type itself, so you can do code:
code:
|
# ¿ Jun 3, 2013 00:26 |
|
ratbert90 posted:Erm, no? Declaring your variables should generally be done well in advance, so that way they have memory assigned to them already. If anything, your variables *should* be in a struct (or object) for code reusability. Why would you declare j over and over and over in different functions if you could just use a single variable in a object or struct that was set at initialization.
|
# ¿ Jun 14, 2013 22:51 |
|
Ephphatha posted:It makes it clearer that the second parameter is used as a size, not a count. Plus the whole sizeof returning a size_t thing.
|
# ¿ Aug 8, 2013 19:58 |
|
Grocer Goodwill posted:Well, you do lose quite a few bugs in your 64-bit build. But 4 gigs ought to be enough for anybody...
|
# ¿ Aug 10, 2013 22:37 |
|
It's like they say: you can't build anything with LEGO until you've mastered injection moulding.
|
# ¿ Sep 25, 2017 14:37 |
|
I put that code into godbolt.org to see what exactly I'd have to do to make clang actually put a runtime typeid lookup in there, and it turns out that you have to not only change typeid(T) to typeid(butt), but you also have to make sure that there are at least two different code paths to the same function call where the compiler can't deduce the actual type of the argument. I did it by instantiating either WeakButt or StrongButt (both subclasses of virtual base class Butt) based on the result of a call to rand(). Even just doing Butt *butt = new WeakButt(); and passing in butt still allowed it to compute the typeid as being WeakButt at compile time.
|
# ¿ Jul 13, 2019 18:32 |
|
If it's affecting subsequent runs in the editor it must be doing something to the editor state that persists after the game is stopped, either clobbering it or stale data not being garbage collected properly would be my initial guesses. If there are static variables being used somewhere they shouldn't be I think that could also cause weirdness like that.
|
# ¿ Mar 14, 2020 16:44 |
|
The documentation says that there's a deprecated FString overload as well as an FText overload, so it could be that the deprecated overload is just broken.
|
# ¿ Mar 15, 2020 02:27 |
|
CMake isn't even a competitor to make so I don't really know where this discussion is coming from. I've rarely seen a project that was literally just a hand-written Makefile, nor would I ever want to write or maintain that. CMake is a competitor to something like autotools, and I'll take CMake any day.
|
# ¿ Dec 17, 2020 19:05 |
|
On Windows I generally just use the installer.
|
# ¿ Sep 19, 2021 14:10 |
|
In all my years of trying I've never found a library that could live up to Qt. GTK isn't terrible, especially in these days of Electron-everything where the old "but it doesn't look native" complaints seem downright quaint, but it doesn't have the breadth of functionality. Once you get the Qt libraries in place either through the installer, vcpkg, or even just building it from source yourself, it's really easy to get it integrated with a CMake project. No need for any of the weird qmake stuff like in the old days.
|
# ¿ Sep 20, 2021 14:32 |
|
CMake seems horrible until you understand that when you give programmers elegant tools to manage build processes with powerful abstractions and clearly defined semantics, they will use those tools to create inscrutable horrors that cause you to go mad just by looking at them.
|
# ¿ Sep 28, 2021 16:46 |
|
Unsigned int should usually mean "raw bit pattern" not "integer value that logically can't be negative". Sometimes even values that can't be negative can be subtracted from and you end up with really stupid bugs when the difference would be negative. Subtracting two vector sizes to get the difference between them? Better make drat sure to check which one's bigger first.
|
# ¿ Jan 4, 2023 18:22 |
|
|
# ¿ May 18, 2024 08:12 |
|
roomforthetuna posted:This but the exact opposite. Classes suck, smart pointers are good.
|
# ¿ Apr 7, 2023 15:16 |