I starting to think that writing my own makefiles will be quicker than trying to get CMake and Qt to work together in order to build a Windows binary on a Linux machine.
I have the following template
template<typename T> void f(T t) { }
And I want to pass the address of a specific specialization of it to a C function
g(&f<int>);
But as I want to be portable, I want the calling convention of "f" to match the one of C. So I experimented how la...
I need some help with my linked list. I think the problem is in the copy constructor or the assignment overload. it keeps giving my segmentation fault when i call:
(Queue test_int_copy(test_int);)
Any other error or poor implementation that you can see would also be very helpful.
the .h file
#...
@kingcong3 the "ggdb" option generates more debugging symbols for gdb. In your particaluar case it's possible that it won't really make a difference though...
don't forget to close your question (and upvote my answer at the same time hahaha, I am so greedy)
And if I can give you some additionnal tips, try to avoid multiple return in a single function. I know that sometime it can help readability, but most of the time it only makes your code spaghetti-like.
Spaghetti code is a pejorative term for source code that has a complex and tangled control structure, especially one using many GOTOs, exceptions, threads, or other "unstructured" branching constructs. It is named such because program flow tends to look like a bowl of spaghetti, i.e. twisted and tangled. Spaghetti code can be caused by several factors, including inexperienced programmers and a complex program which has been continuously modified over a long life cycle. Structured programming greatly decreased the incidence of spaghetti code.
Examples
Below is what would be considered...
Why is this rvalue call ambiguous? I can have AA and AA& and the compiler will know to use AA&. But when i add in the third option i get an error. Obviously AA&& is a better overload then the others like int for an int is better then long. Why is this ambiguous? Is there a way i c...
By including you .cpp in your .h, you will have to recompile the entire project everytime, because nothing is compiled in .cpp and everything is done in the main.cpp
very wrong
please, fight for this, don't let this happen
about your problem, you can't just declare template <class Object> in a .cpp
it must be followed by a function declaration or a class declaration
@StackedCrooked what do you mean "It's a local thing"? Where you are you have your own version of a global standard? A deceleration will set some value to a variable or function. Although close, a definition is not the same as a deceleration
@Tony I think I need to be in from 11-4. But if I have some appointment during the day, I just need to tell. The idea is to be able to schedule meetings in that time without having to ask everyone when they'll be in, not to bind us to our chairs.
@sbi my lecture a couple of weeks ago (I hope this was just a brain fart) was talking about the view frustum, and said, "what ever shape that is in maths" my instant response was "erm... a frustum?"
@StackedCrooked honestly, yes kind of. What is the point in having a standard, if people are just going to make up their own version of it?
I appreciate that this is a small and rather trivial point. But if we (as a community) agree what the basics are, how can we talk about the most abstract notions?
I.e. imagine that two classes A and B can be implicitly converted to each other in more than one way: A::A( B const & ), B::operator A(), then having an implicit conversion will trigger an ambiguity error: (A)B() the compiler cannot determine which of the two conversions to use, but you could disambiguate by explicitly selecting the path: A( B() ) -- use A::A(B const& ), or B().operator A()
I would avoid doing it, then if the compiler barfs, go back and try to solve it
I do personally think that using wchar_t is the worse part of that statement. wchar_t is not guaranteed to be the same size as WCHAR, or OLECHAR which is what a BSTR is.
@ChrisBecke That is a bad practice, the problem is that you have lost control of the conversion there, and if someone changes something somewhere (some*), it might turn from a static_cast<> into a reinterpret_cast<> with UB
likewise, LONG should be used in place of long in Winapi code, as long is 64bits on some compilers, but LONG is 32bits under both Win64 and Win32 APIs
@DavidRodríguezdribeas so then, W2A( _bstr_t(bstrVar).operator LPCWSTR()); might be considered best practice, except for one small thing. bstrVar looks like its a BSTR value, which is, already, a WCHAR*
Of course, Windows NT is natively unicode, so it means that, as soon as you make any API call, the OS has to do the reverse: A2W() on every string passed as a parameter.
If you can, convert the app to unicode and just skip the W2A step entirely.
@Tony Declaring implicit conversion operators/constructors is usually considered bad practice in C++. (That's why there's the explicit std::string__c_str(), after all.) I have certainly been bitten and learned to shy away from them the hard way. Once they are defined, however, using them explicitly I wouldn't call that much of a sin.
What is this code (W2A(_bstr_t(bstrVar).operator wchar_t*())) supposed to do anyway? Wouldn't the bstr prefix to bstrVar mean that it already is a _bstr_t? (And, by inference, that bstrVar is an exceptionally bad variable name.)