|
[SOLVED] Using Visual Studio 2008, how can I output a DLL for both 32bit and 64bit systems? "Any Key" doesn't appear in the MSVS help files either which is what I read I have to use. *EDIT I found the "Platform" option in my project settings, but it is set to Win32 and that is the only option. So I have a DLL that is set to Win32 and works on a 64bit machine and not a 32bit machine. This doesn't make sense! *EDIT2 Installed C++ redistributable on 32bit test machine and it now works. RonniePudding fucked around with this message at 19:17 on May 26, 2010 |
# ? May 26, 2010 18:48 |
|
|
# ? Jun 8, 2024 18:07 |
|
I realized that something like: code:
|
# ? May 27, 2010 01:04 |
|
Perhaps this is a wrong thread to ask for this, but can somebody recommend me good books and/or online materials for learning MPI from scratch? Also feel free to share your experience in learning and using it.
|
# ? May 27, 2010 01:10 |
|
slovach posted:I realized that something like: I believe statics/globals get filled with default/zero already, but for local variables you can rely on the above, yes.
|
# ? May 27, 2010 01:14 |
|
Yes. Here's how you zero-initialize an array: int a[N] = {};. The same principle holds for initializing C-style strings. (Stop using memset for that, my precious coworkers)
|
# ? May 27, 2010 01:20 |
|
slovach posted:I realized that something like: Yes, for two reasons: 1. Everything with static storage duration (i.e. variables with global scope, static local variables, and static data members) is guaranteed to be zero-initialized at program start even if not otherwise initialized. So you could write code:
2. When an aggregate (i.e. a struct or array) is initialized with an initializer list, missing members are value-initialized (which is the same as zero-initialized for ints).
|
# ? May 27, 2010 01:22 |
|
Mustach posted:Yes. Here's how you zero-initialize an array: int a[N] = {};. The same principle holds for initializing C-style strings. (Stop using memset for that, my precious coworkers) Note that you need at least one value in your initializer list for C.
|
# ? May 27, 2010 01:55 |
|
Dang, that was a perfect opportunity for you to use .
|
# ? May 27, 2010 05:22 |
|
LockeNess Monster posted:Perhaps this is a wrong thread to ask for this, but can somebody recommend me good books and/or online materials for learning MPI from scratch? Also feel free to share your experience in learning and using it. I've not used MPI directly; I found it much easier to use Pilot on top of it. If you're doing low level wizardry this won't be useful to you, but for general use, it provides a much smaller and cleaner interface and semantics than using raw MPI does. Basically, it's a semisynchronous message passing library with runtime deadlock detection implemented on top of MPI. There are also Fortran, Python, and Lua bindings for it in varying levels of maturity, if that's what turns your crank.
|
# ? May 27, 2010 05:55 |
|
ToxicFrog posted:I've not used MPI directly; I found it much easier to use Pilot on top of it. If you're doing low level wizardry this won't be useful to you, but for general use, it provides a much smaller and cleaner interface and semantics than using raw MPI does. Basically, it's a semisynchronous message passing library with runtime deadlock detection implemented on top of MPI. For the person asking the question: I've used this one and it's pretty good.
|
# ? May 27, 2010 15:49 |
|
I have a large array that I need to divide into 4 smaller arrays. buffer -----------> ( buffer_1 , buffer_2 , buffer_3 , buffer_4 ) The only way I know how to do this is iterating to each value, which is really slow: code:
2.) Are there any boost functions that could help with this? 3.) Should I use a vector rather than an array? *EDIT It's also important that the array retains the original order RonniePudding fucked around with this message at 01:24 on May 28, 2010 |
# ? May 28, 2010 01:21 |
|
code:
|
# ? May 28, 2010 01:23 |
|
Whoa so that will shift the starting address by the offset? If so I love you and I mean it.
|
# ? May 28, 2010 01:25 |
|
of course, AD's approach doesn't make a copy of the array since it's just doing pointer arithmetic. If you expect the original array to be modified elsewhere, or if you want to split the array several times into distinct copies which themselves will be changed, you'll have no choice but to copy the array. edit: if you have to copy the array, at the very least use something like memcpy.
|
# ? May 28, 2010 01:29 |
|
It will, but be careful about memory management. You need to free/delete buffer (or equivalently buffer_1 if its offset is 0), not the others.Dijkstracula posted:edit: if you have to copy the array, at the very least use something like memcpy. Don't do this if you have an array of non-POD types (i.e. most anything except primitive types and "C-style" structs).
|
# ? May 28, 2010 01:30 |
|
Avenging Dentist posted:Don't do this if you have an array of non-POD types (i.e. most anything except primitive types and "C-style" structs).
|
# ? May 28, 2010 01:55 |
|
Avenging Dentist posted:Don't do this if you have an array of non-POD types (i.e. most anything except primitive types and "C-style" structs). 0x will get a little more lenient with what it considers a POD type but I'm too lazy to a description of the changes
|
# ? May 28, 2010 01:59 |
|
Otto Skorzeny posted:0x will get a little more lenient with what it considers a POD type but I'm too lazy to a description of the changes Inheritance is legit if only one class in the inheritance hierarchy has non-static members (this means CRTP can be used with PODs ). Also you can have non-default constructors now by explicitly setting the default constructor to the trivial case: constructor() = default;. There's some other stuff, but it doesn't really matter.
|
# ? May 28, 2010 02:04 |
|
Dijkstracula posted:of course, AD's approach doesn't make a copy of the array since it's just doing pointer arithmetic. If you expect the original array to be modified elsewhere, or if you want to split the array several times into distinct copies which themselves will be changed, you'll have no choice but to copy the array. I'm using a memmove() right after a memcmp() so this solution is perfect. Before I was doing: code:
code:
RonniePudding fucked around with this message at 03:29 on May 28, 2010 |
# ? May 28, 2010 03:23 |
|
I've got a .Net COM server, and I want to pass an object to that server from a C++ client. I've got no problem creating the COM server object on the C++ end. My server object (.Net) has a method that looks like this: public void RegisterCallback(object callback) And this method is visible to me in my C++ client. I've got an object in C++ that just defines a simple method that returns an int (just for testing/proof-of-concept purposes). code:
When I call the RegisterCallback() method in my C++ code, passing in an instance of CppClient, it's trying to marshal that object as a bool, which obviously isn't working. I probably have to do some more COM-related stuff with CppClient, but I'm just not sure what that "stuff" is. Can anyone help point me in the right direction? Thanks. edit: finally got this figured out. If anyone cares about the solution, I'd be happy to post it. _aaron fucked around with this message at 20:33 on May 28, 2010 |
# ? May 28, 2010 16:41 |
|
_aaron posted:I've got a .Net COM server, and I want to pass an object to that server from a C++ client. I've got no problem creating the COM server object on the C++ end. My server object (.Net) has a method that looks like this: Can you? Awhile back at my past job i spent awhile trying to figure out the best way to do that (i never did COM before). I ended up coming up with a horrific solution so i would love to see how to better do it.
|
# ? May 30, 2010 02:05 |
|
http://article.gmane.org/gmane.comp.gcc.devel/114407
|
# ? May 31, 2010 16:37 |
|
Otto Skorzeny posted:http://article.gmane.org/gmane.comp.gcc.devel/114407
|
# ? May 31, 2010 16:59 |
|
Clearly if they just switch to C++ (that is, saying class instead of struct and maaaaaybe using member functions), they will catch up to clang in no time!
|
# ? May 31, 2010 17:01 |
|
Vanadium posted:Clearly if they just switch to C++ (that is, saying class instead of struct and maaaaaybe using member functions), they will catch up to clang in no time! Eh, they're talking about using constructors and destructors and STL which really is a big improvement. No templates is still a sad sight, though. Either way, there's no way they'll catch up if the Clang train passes them by, which in some ways it already has.
|
# ? May 31, 2010 17:23 |
|
fixd
Pivo fucked around with this message at 23:24 on May 31, 2010 |
# ? May 31, 2010 22:08 |
|
Otto Skorzeny posted:http://article.gmane.org/gmane.comp.gcc.devel/114407 They're really arguing about which type of coal to fuel the steam engine there.
|
# ? Jun 1, 2010 13:12 |
|
Vanadium posted:Clearly if they just switch to C++ (that is, saying class instead of struct and maaaaaybe using member functions), they will catch up to clang in no time! Well, at least more of them might notice just how slow compiling C++ code is with gcc.
|
# ? Jun 1, 2010 19:06 |
|
I am having a small transition from Python to learn some new stuff and I have a simple question, but first I have to explain my problem. In Python I made a class called "node" which I used to simulate a hierarchical structure. It had several attributes like name, depth, parent and children among others. My question regards the list of children which contained objects, or references to other instances of the class node. How can I simulate this in C++? Can I create an array/list in my object which can contain references/pointers to other object? Below is a brave attempt to explain what I mean in some C++-like pseudocode. code:
|
# ? Jun 3, 2010 00:32 |
|
C/C++ arrays are necessarily fixed-length, so if you want to story an arbitrary number of children in an array, you'll need a data structure which can resize that array. The STL provides a generic resizable-array data structure called std::vector, so if you wanted a vector of pointers to nodes, you'd have something like:code:
|
# ? Jun 3, 2010 00:48 |
|
Thanks for the reply, but I am running into some problems. I have no understanding of vectors so I am not able to analyze the code. The compiler tells me that I cannot declate a vetor with no type. I am guessing the compiler does not read "Node" as a type, but I may be horribly wrong. I would appreciate any elaboration or some advice as to how to do what I want. code:
|
# ? Jun 3, 2010 01:04 |
|
Works fine over here: http://codepad.org/u4vlf9K9 (Your code is broken because 1) you aren't declaring i, and 2) you're trying to use a pointer like a value type).
|
# ? Jun 3, 2010 01:08 |
|
Here is some sample code: http://codepad.org/TOTixB1a Same code is pasted here if you don't want to click: code:
CircleInterface extends ShapeInterface, and CircleImpl extends ShapeImpl (while also implementing CircleInterface). The error that the compiler throws is: cannot declare variable 'circle' to be of abstract type 'CircleImpl'. My problem is with the 2 SetName/GetName methods. They are defined in ShapeInterface, and implemented in ShapeImpl. However, it seems like I have to implement them in CircleImpl as well (even if they are just calling ShapeImpl::SetName()/ShapeImpl::GetName()). Am I doing something wrong, or this is the way it's supposed to happen in C++. Coming from Java, this construct (extend A implement B) is perfectly valid and I do not have to implement any methods that A defines that are implemented in B. Can it be done in C++ too? Or will I just have to live with it?
|
# ? Jun 3, 2010 02:22 |
|
Use virtual inheritance: http://codepad.org/Q21fhVP1
|
# ? Jun 3, 2010 02:27 |
|
Avenging Dentist posted:Use virtual inheritance: http://codepad.org/Q21fhVP1 Thank you sir.
|
# ? Jun 3, 2010 02:32 |
|
Simple question, I have a file1.cpp which includes file1.h with a struct and a class defined in there. The class uses a struct defined in file2.h. file2.cpp includes file2.h, file2.h also includes file1.h because a class defined in file2.h uses the struct defined in file1.h. If I do this I get an error, how should this type of stuff be done correctly?
|
# ? Jun 3, 2010 10:55 |
|
Le0 posted:Simple question, Can you reproduce this in a couple of small stripped-down files and post the source and the error?
|
# ? Jun 3, 2010 13:46 |
|
It's almost certainly a cyclic dependency, you need to forward declare one of the classes. (file1.h) code:
code:
|
# ? Jun 3, 2010 13:50 |
|
UberJumper posted:Can you? Awhile back at my past job i spent awhile trying to figure out the best way to do that (i never did COM before). I ended up coming up with a horrific solution so i would love to see how to better do it. Basically, what we did was define an interface in our C# server app (call it IClient) and made this interface COM visible. We also changed the Register method on the server object to take in an IClient rather than an object. After building our .tlb file, we can set up the C++ client. The client application needs to implement a class that implements the IClient interface. Part of exposing that interface to COM means that on the C++ end, IClient inherits from IDispatch (msdn), which in turn inherits from IUnknown (msdn) (both of which should be somewhat familiar if you struggled with COM for any amount of time ) We were mainly just doing this as a proof of concept (showing that our C# server could work with a C++ client), so our implementation of IDispatch is almost certainly wrong. But it worked for our purposes, and with a little tweaking could probably be made correct. Here's the code for the C++ implementation of the interface. If there's anything else you'd like to see, let me know. If you've got a specific question, I can try to explain a little better, but like I said, this was just a proof of concept, and I'm really not sure that I understand it all that well myself. Good luck
|
# ? Jun 3, 2010 14:29 |
|
|
# ? Jun 8, 2024 18:07 |
|
ultra-inquisitor posted:It's almost certainly a cyclic dependency, you need to forward declare one of the classes. You can't forward declare a type you are using as a base.
|
# ? Jun 3, 2010 14:52 |