|
That looks like a circular dependency to me.
|
# ? Oct 11, 2014 02:06 |
|
|
# ? Jun 7, 2024 09:43 |
|
Mr. Crow posted:I'm learning gtest and c++ and can't wrap my head around how to do this, any guidance? I am not sure I really understand your question, but TYPED_TEST and TYPED_TEST_CASE may be of use. https://code.google.com/p/googletest/wiki/AdvancedGuide#Typed_Tests (Or alternatively TYPED_TEST_P)
|
# ? Oct 11, 2014 02:27 |
|
OddObserver posted:I am not sure I really understand your question, but TYPED_TEST and TYPED_TEST_CASE may be of use. The question is thus, how do I create type-parameterized tests for a templated class? Type-Parameterized Tests seem to be what I want, but they only accommodate a single parameter (e.g. the derived class) so it seems to not work for templated types (e.g. the templated base class being tested), and I'm not seeing an alternative solution in their documentation.
|
# ? Oct 13, 2014 15:14 |
|
I've installed the OSI library using this [url=http://www.coin-or.org/download/binary/CoinAll/COIN-OR-1.7.4-win32-msvc11.exe[/url] and I'm trying to compile a minimum working project using VS 2012 Ultimate. The file, minimum.cpp, here here and it's in a win32 console application with precompiled headers off and character set to "Not Set". The file initially had the #include statements underlined in red, but then I added the library and include directories to "Linker > General > Additional Library Directories" and the "C/C++ > Additional Include Directories" in the project's Configuration Properties respectively. The red underlines went away. However, when trying to build (debug or release mode) I get lots (9) of errors like: Error 1 error LNK2019: unresolved external symbol "public: virtual __thiscall OsiSolverInterface::~OsiSolverInterface(void)" (??1OsiSolverInterface@@UAE@XZ) referenced in function "public: void __thiscall OsiClpSolverInterface::`vbase destructor'(void)" (??_DOsiClpSolverInterface@@QAEXXZ) C:\code\phd\osi\ConsoleApplication1\ConsoleApplication1\MinimumOSI.obj MinimumOsi I added the /VERBOSE option to the build so that it'd list all the libraries that it's searching for. However, none of the libraries I've added (as mentioned above) show up in the output at all. If the red underlines went away, does that mean that VS recognises the library files, so why won't the linker?
|
# ? Oct 13, 2014 16:47 |
AlsoD posted:If the red underlines went away, does that mean that VS recognises the library files, so why won't the linker? No, just that the IDE found some header files defining the names. It never looks past that, specifically does not look into what might happen during link. You probably also need to add the actual library names to the configuration.
|
|
# ? Oct 13, 2014 17:00 |
|
The option you want is in Linker > Input (if I'm remembering correctly). Add actual .lib names, not just directories.
|
# ? Oct 13, 2014 17:08 |
|
http://isocpp.org/files/papers/N4174.pdf Bjarne being Bjarne
|
# ? Oct 13, 2014 17:12 |
|
nielsm posted:You probably also need to add the actual library names to the configuration. GrumpyDoctor posted:The option you want is in Linker > Input (if I'm remembering correctly). Add actual .lib names, not just directories. Thank you. Is there a way to tell which .lib files I want? They're not in the same naming convention as the .hpp files. Failing that, would adding "path/to/dir/*.lib" work or do I really need to add all 39 (or some subset thereof) separately? I've tried calling DUMPBIN /SYMBOLS but the output is unreadable and very long, I suppose I could write a batch script to search through it all for the symbols I want, if needed.
|
# ? Oct 13, 2014 17:17 |
AlsoD posted:Thank you. Is there a way to tell which .lib files I want? They're not in the same naming convention as the .hpp files. Failing that, would adding "path/to/dir/*.lib" work or do I really need to add all 39 (or some subset thereof) separately? The short version is "all of them" and "possibly also including those in the intel subdir". As long as you only have libraries for one platform/compiler settings combination in a single directory, including unneeded ones rarely hurts, since modern linkers usually avoid linking code never called by anything. The long version is that you should be using a build script that calls the included pkg-config.exe with appropriate environment and parameters and have it return a list of libraries needed.
|
|
# ? Oct 13, 2014 17:29 |
|
That did the trick, I have it compiling (but not running yet of course) now. Visual Studio certainly seems very heavy duty and intimidating compared to the CLI compiling of small projects that I'm used to.
|
# ? Oct 13, 2014 17:48 |
|
Now with regards to getting it running: the installer for the library (linked above) installed libmmd.lib, but no libmmd.dll. When the VS option "runtime library" is set to /MD (multithreaded dynamic), the generated executable will crash with "The program can't start because libmmd.dll is missing from your computer". When the option is set to /MT (presumably multithreaded static), the compiler will fail with a whole bunch of "mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'" errors. Is it possible that the provided binaries were compiled dynamically but only the static libraries were included with the distribution? Can I generate a .dll from a .lib file? Looking around, libmmd seems to be part of intel's fortran compiler which I'm certainly not about to buy.
|
# ? Oct 14, 2014 14:22 |
|
The runtime library isn't the issue - leave it set to multithreaded dynamic. I'm guessing that libmmd.dll is a redistributable library, which means you can get it freely without having to buy the compiler. You might try one of these.
|
# ? Oct 14, 2014 15:25 |
|
GrumpyDoctor posted:The runtime library isn't the issue - leave it set to multithreaded dynamic. I'm guessing that libmmd.dll is a redistributable library, which means you can get it freely without having to buy the compiler. You might try one of these. That was exactly it thanks, it's now working perfectly. Christ I wish I'd asked here a week ago.
|
# ? Oct 14, 2014 16:01 |
|
Don't feel too bad. Whoever built that installer you used messed up; the whole point of redistributable libraries is to redistribute them. e: Actually, come to think of it, it might have but just not put it in your PATH. raminasi fucked around with this message at 16:14 on Oct 14, 2014 |
# ? Oct 14, 2014 16:09 |
|
There certainly wasn't any dll files included with the install (of the original library, COIN-OR) whatsoever.
|
# ? Oct 14, 2014 16:58 |
|
I feel like a doofus because I've apparently forgotten how to use stringstreams. Why does this cause pName to end up as -52 (a capital "I" with an accent on it) and then size to be 0 when I type "Request A 1024"?C++ code:
|
# ? Oct 14, 2014 20:08 |
|
hooah posted:I feel like a doofus because I've apparently forgotten how to use stringstreams. Why does this cause pName to end up as -52 (a capital "I" with an accent on it) and then size to be 0 when I type "Request A 1024"? "cin >> request" breaks at whitespace. you want getline. also print out pName before and after you attempt to read into it from the stringstream. stringstreams silently fail FamDav fucked around with this message at 20:20 on Oct 14, 2014 |
# ? Oct 14, 2014 20:15 |
|
FamDav posted:"cin >> request" breaks at whitespace. you want getline. also print out pName before and after you attempt to read into it from the stringstream. Ahh, getline, thanks! (And I know I didn't initialize pName; I temporarily forgot how to represent the null character.)
|
# ? Oct 14, 2014 20:47 |
|
FamDav posted:stringstreams silently fail It's trivial to test for failure... C++ code:
|
# ? Oct 14, 2014 20:50 |
|
I have never understood the sort of thinking that would end up with iostream as an API.
|
# ? Oct 15, 2014 06:43 |
|
Suspicious Dish posted:I have never understood the sort of thinking that would end up with iostream as an API. "Let's design an API purely to show off how powerful our operator overloading feature is"
|
# ? Oct 15, 2014 09:32 |
|
I'm trying to program a Linked List in C++. This is part of my code:C++ code:
I found that if I cut the implementation for that function and pasted it within the class declaration, it compiles, ie if I do this: C++ code:
|
# ? Oct 16, 2014 09:10 |
|
You need to call it LinkedList::Element in the return type of the definition.
|
# ? Oct 16, 2014 09:17 |
|
Scope resolution operator: LinkedList::Element* LinkedList::ElementAt(int index){};
|
# ? Oct 16, 2014 09:22 |
|
Baron Bifford posted:I'm trying to program a Linked List in C++. This is part of my code: The compiler is telling you it doesn't know what an "Element*" is in that scope. LinkedList::ElementAt should return LinkedList::Element* instead of Element*, and ptr_first in LinkedList::ElementAt should be declared as a LinkedList::Element* instead of Element*.
|
# ? Oct 16, 2014 09:24 |
|
Doh. Seems so obvious now.
|
# ? Oct 16, 2014 09:26 |
|
Is there a library (standard or otherwise) to transform character literals to html special characters? E.g. something like \n to <br/>?
|
# ? Oct 17, 2014 14:30 |
Mr. Crow posted:Is there a library (standard or otherwise) to transform character literals to html special characters? E.g. something like \n to <br/>? That's a really bad example. Mainly because <br> is not an SGML entity, but a tag. Maybe try an XML library. Or just a dumb string-replace, you can get a data file here: http://www.w3.org/TR/html5/entities.json If you instead want to transform human-readable-ish text into HTML with decent formatting, maybe try Markdown.
|
|
# ? Oct 17, 2014 15:19 |
|
I'm doing a project that pretends to implement the buddy system of memory allocation. I want to store the address and process name (a char) in a data structure that gets sorted by address whenever a new element is added. Here's the class that should do that:C++ code:
C++ code:
|
# ? Oct 18, 2014 16:25 |
|
Probably just comp() in std::sort(mAllocated.begin(), mAllocated.end(), comp()).
|
# ? Oct 18, 2014 16:27 |
|
MSVC's emplace_back doesn't work right and might be causing your problem.
|
# ? Oct 18, 2014 16:29 |
|
Vanadium posted:Probably just comp() in std::sort(mAllocated.begin(), mAllocated.end(), comp()). Nope. With the struct version, I get the "no conversion from 'int' to 'Process *'" error, and with the plain function version, I get an error that 'comp' does not take 0 arguments. GrumpyDoctor posted:MSVC's emplace_back doesn't work right and might be causing your problem. FFS. I'll give this a shot.
|
# ? Oct 18, 2014 16:29 |
|
The usage of emplace_back there would be fine if mAllocated were a code:
code:
|
# ? Oct 18, 2014 17:39 |
|
hooah posted:I'm doing a project that pretends to implement the buddy system of memory allocation. I want to store the address and process name (a char) in a data structure that gets sorted by address whenever a new element is added. Here's the class that should do that: Since your particular purpose has more to do with ordering and single insertions, and less to do with random access, a set isn't entirely appropriate, but it would be better than the append-then-sort operation you're doing, especially since you're doing it on a vector. And it would be less error prone because you can't ever neglect to keep it properly ordered.
|
# ? Oct 18, 2014 17:45 |
|
GeneralZod posted:The usage of emplace_back there would be fine if mAllocated were a what crazy carl said you either need to store a shared_ptr, unique_ptr, or the actual type itself. unless you start sharing the data around, you probably just want vector<Process>
|
# ? Oct 18, 2014 18:18 |
|
roomforthetuna posted:You could just use a std::set for this, with a comparison 'struct' (like you used for a priority_queue) specified in the declaration. 'set' is a horrible misnomer for this template because (even when it's not a red-black tree) the spec of std::set is that it is an ordered thing, which a mathematical set is not. But this is a pretty good match for what you want. This sounds like a good approach, thank you. We really only did non-vector collections for a couple weeks (a year ago), so I don't think about them enough. I'll give this a shot tonight.
|
# ? Oct 18, 2014 20:39 |
|
Ok, set seems like it might be working better, but I'm having trouble with my ::remove function. Since I'm putting objects into the set, I can't just do mySet.erase(someProcess); I have to search for the proper object with an iterator and use that to erase something. The problem I have now is defining the return type for my search function. I figured I'd just have the compiler do it and say decltype(mAllocated.begin()) search(Process);, but I get an error "C2228: left of '.begin' must have class/struct/union". Then on my return line ("Return iter"), I get "C2440: 'return': cannot convert from 'std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<Process>>>' to 'int'". The last error especially doesn't make much sense to me since 'int' definitely shouldn't be the type of mAllocated.begin(), but I guess it is?
|
# ? Oct 19, 2014 00:59 |
|
Why are you writing your own search function? Or, for that matter, your own erase function?
|
# ? Oct 19, 2014 01:03 |
|
Because when the client program wants to erase something, it'll ideally just give a char that is the process's name, and unless I'm misunderstanding it, set::find takes the same type as what the set stores. I suppose I could re-write the client program to create the Process objects itself, but I'd hoped to avoid having the client know about what seems like internal implementation details.
|
# ? Oct 19, 2014 01:12 |
|
|
# ? Jun 7, 2024 09:43 |
|
hooah posted:Because when the client program wants to erase something, it'll ideally just give a char that is the process's name, and unless I'm misunderstanding it, set::find takes the same type as what the set stores. I suppose I could re-write the client program to create the Process objects itself, but I'd hoped to avoid having the client know about what seems like internal implementation details. Well, in that case, you still don't need to roll your own search.
|
# ? Oct 19, 2014 01:18 |