|
Googling for that comment finds this: http://profile.iiita.ac.in/IEC2008063/Documents/study/imp books/adc/Microsoft Visual Studio 9.0/VC/ce/crt/src/xexp.c And a bunch of similar files. Seems like some sort of source file for FP routines in MSVC runtime library has some floating point array, and the auto-completion indexed it somehow.
|
# ? Jul 16, 2010 06:09 |
|
|
# ? Jun 8, 2024 17:43 |
|
Figures I should have just googled it
|
# ? Jul 16, 2010 06:21 |
|
I'm trying to pass a string from C++ to C#. Here is what I have right now: My C++ exported function: code:
code:
code:
|
# ? Jul 16, 2010 13:10 |
|
"Some problems" could be anything, but I'm going to guess that it's because you're returning a temporary std::string's c_str(). The result of c_str() is owned by the std::string object, and so will be deleted when the object's scope ends (in this case, the end of the statement which assigns it to *jsArray). You'll need to make a dynamically-allocated copy of the C-style string and return that. This means you'll have to make an API function deleteJavascript() or something like that, and call it after you assign to jsString in the C# code like this:code:
|
# ? Jul 16, 2010 14:10 |
|
Thanks for the reply Mustach. I tried your method but still get no output. What's strange is that I can output the result into a log file just fine: code:
So this leads me to believe the problem is somewhere in the C# and how it is reading the string.
|
# ? Jul 16, 2010 14:25 |
|
I hate to poo poo up the thread with my newbie nonsense again, but I have another question concerning socket operations. The code that I've been given seems to be having trouble with socket permissions, but I'm not really sure what to do about it in this case. This: code:
code:
|
# ? Jul 16, 2010 14:27 |
|
RonniePudding posted:Thanks for the reply Mustach. I tried your method but still get no output. code:
quote:What's strange is that I can output the result into a log file just fine:
|
# ? Jul 16, 2010 15:43 |
|
Mustach you are a god amongst men. That works perfectly!
|
# ? Jul 16, 2010 16:13 |
|
slovach posted:
It's me. I'm Tim Prince. Enjoy your assorted numbers; you're welcome. Seriously though this freaked me out because I have the same name as the guy in the comment.
|
# ? Jul 17, 2010 02:44 |
|
Dumb question, but I dig the details: In classes where I make heavy use of STL containers, I'm creating iterators locally in a majority of those classes' methods. You can only type code:
|
# ? Jul 17, 2010 04:10 |
|
Maybe if you do typedef std::vector<Entity*>::iterator my_iter it will be more managable, maybe you can also have a function begin() that just returns mEntities.begin(), i do not think keeping iterators around makes that much sense
|
# ? Jul 17, 2010 04:21 |
|
Pretty much the most (only?) sensible way of implementing a std::vector<T>::iterator is as a struct/class that contains only a T*. No allocations or other heavy-duty stuff involved. If anything, putting it into a local may end up wasting memory. .. And extending scope of variables beyond when they're needed is a bad idea. For example, if you're not careful, you might end up using the same "cached" iterator in 2 functions that may end up (perhaps indirectly) called from each other.
|
# ? Jul 17, 2010 04:27 |
|
I'm trying to find a good container either in STL or boost that'll store a list of things in an order, using an operator I define, but also has some awareness of the individuality of the objects it contains. I don't think I'm being too clear so I'll just say what screwed me up tonight. I was using a set with a compare operator that worked on one particular field of a class I wanted sorted. It turned out that if I had two objects where that one field happened to be equal, then subsequent insertions would fail. After all, a value of that key type was already in there. So I switched to a multiset. Now the problem is if I want to erase a particular object from the multiset, it will whack everything that matches that particular object's key. So what I wanted instead was something that will sort on the key but does something like a complete equality check when it comes time for deletion. And I was hoping for a complexity better than linear, which is what got me into using sets in the first place.
|
# ? Jul 19, 2010 07:50 |
|
Define a strict total order for your class so that two different objects aren't equal.
|
# ? Jul 19, 2010 10:25 |
|
Plorkyeran posted:Define a strict total order for your class so that two different objects aren't equal. I wish I had thought of that last night, but I think I was generally frustrated.
|
# ? Jul 19, 2010 16:28 |
|
I'm working on a C++ project in Visual Studio 2008 which uses several external libraries. Everything works fine in debug mode, but when I try to compile for release or in MT configuration (as opposed to MD or MDd), I get a stream of linker errors and warnings that make my head spin because I know relatively little about compiling and linking to external libraries. When I run the project on another computer, I get a side-by-side configuration error. Regardless of configuration, I always get a couple of macro redefinition warnings (APIENTRY and WINGDIAPI in glfw.h) and a warning that "defaultlib 'MSVCRTD' conflicts with use of other libs." When I set the runtime library to Multi-Threaded (non-DLL), I get linker errors complaining that a bunch of standard library functions (_malloc, _free, _memmove, _feof) are already defined in LIBCMT.lib. (Full build log) One issue, I've been led to believe, is that some libraries have been compiled under different versions than others, or in different configurations. GLFW is a library which provides some window management and input handling functionality for OpenGL, and it also relies on opengl32 and glu32. If I download it from glfw.org, I get headers and precompiled library files. The source has a makefile, but the highest version of Visual Studio it includes is MSVC++ 2005. Is this something a need to be concerned about in attempting to fix the problems I'm having with building and linking? Is there a workaround that I could use, or is the best course of action to identify and rectify the conflicts? From what I've researched it seems like both are a possibility, but I'm not really competent enough as it is to follow through with the latter. More generally, does anyone know of any resources that would help me understand the mystic art of linking any better?
|
# ? Jul 19, 2010 23:12 |
|
Debug runtimes don't come preinstalled and aren't licensed for redistribution, so if you haven't explicitly installed them or Visual Studio on a computer you can't run debug builds which dynamically link the runtime. Everything being linked together to form an executable needs to link against the same version of the runtime library. Switching only one thing between debug and release or static and dynamic runtime linking produces the linker errors you're seeing.
|
# ? Jul 19, 2010 23:31 |
|
What determines which version of the runtime library a particular piece of object code links against? For example, if I had been building in debug mode and I wanted to start building in release mode, would I need to recompile the libraries against which I'm linking (OpenGL, GLU, GLFW, SOIL, OpenAL, Box2D) in release mode as well?
|
# ? Jul 19, 2010 23:44 |
|
In general, if you are linking against a library that you are compiling yourself you'll need to build both debug and release versions of it, and if you're linking against supplied binaries you have to hope that they're supplying binaries built in the configurations you need. Note that if you toss all of your dependencies into the solution with your project and set your project to depend on them (rather than building them separately and explicitly passing the .lib to the linker), visual studio does 90% of the work of ensuring that you're linking against the right things for you.
|
# ? Jul 20, 2010 00:06 |
|
I would like to mmap a large amount of MAP_ANONYMOUS memory. I would like to page in and reserve all the memory for my process. If I cannot immediately page in all of the addresses because there is not enough memory I would would like for the command to fail gracefully in some way. What is currently happening is that the system allows the mmap to return successfully, but then later on as those addresses are accessed and it tries to make new pages available it shortsightedly runs out of reserves and segfaults. I am aware that this problem is somewhat built-in to Linux and Linux-like systems. I am looking for workarounds.
functional fucked around with this message at 03:34 on Jul 20, 2010 |
# ? Jul 20, 2010 03:32 |
|
functional posted:I would like to mmap a large amount of MAP_ANONYMOUS memory. I would like to page in and reserve all the memory for my process. If I cannot immediately page in all of the addresses because there is not enough memory I would would like for the command to fail gracefully in some way. What is currently happening is that the system allows the mmap to return successfully, but then later on as those addresses are accessed and it tries to make new pages available it shortsightedly runs out of reserves and segfaults. I am aware that this problem is somewhat built-in to Linux and Linux-like systems. I am looking for workarounds. If you want to ensure that you have backing store available for a piece of memory, you can do so by allocating your own swap for that memory ahead of time. First, create a temporary file, and immediately unlink it from the filesystem while retaining its filehandle. truncate(2) it to the correct size, or actually write to it until it's the correct size if you want to force a ENOSPC error right away in the event of low diskspace. mmap it MAP_SHARED (you hold the only reference to this inode, so no-one else will step on your feet). This memory will be available to your process no matter what else is going on with the system, because its resources are completely private to your process. The downside, of course, is that you are no longer using the system's normal swap space, but are occupying space on some random potentially-slow filesystem instead. This problem is trivially avoided by creating the file on a tmpfs mount, which is what most systems provide for /tmp nowadays.
|
# ? Jul 20, 2010 03:52 |
|
ShoulderDaemon posted:Great explanation Wow, thanks! Is there any way to separate memory that's "in memory" from memory that's "on the disk?" It would be helpful to restrict some allocations to fast memory so you don't have the delay of going to the disk.
|
# ? Jul 20, 2010 04:33 |
|
Plorkyeran posted:In general, if you are linking against a library that you are compiling yourself you'll need to build both debug and release versions of it, and if you're linking against supplied binaries you have to hope that they're supplying binaries built in the configurations you need. Thanks a ton for the advice; you made my day.
|
# ? Jul 20, 2010 05:14 |
|
functional posted:Wow, thanks! I am not sure what you are asking exactly but if you use the mlock family of functions you can prevent some pages from ever going to backing store, and use those as your "fast memory". If you aren't running as root, you are typically restricted to locking a very small number of pages in this manner.
|
# ? Jul 20, 2010 06:13 |
|
Since C and C++ are actually not the same language but rather loosely related standards governed by two different standards bodies: is anyone in favor of splitting this thread into a "C" megathread and a "C++" megathread? Since it seems to be mostly C++ questions here I say "C" should be a new thread.
|
# ? Jul 21, 2010 10:38 |
|
Are there enough C questions for its own thread?
|
# ? Jul 21, 2010 13:50 |
|
While I agree with the idea of rounding up all C programmers and placing them in re-education camps, I don't think this is the thread to start it as C questions are extremely rare.
|
# ? Jul 21, 2010 13:54 |
|
We could deport them to the coding horror thread
|
# ? Jul 21, 2010 14:10 |
|
Most regulars to this thread know the distinctions between the two languages and even when one gets something wrong, somebody else usually corrects them. In fact, I think it's better that C and C++ share a thread so that those distinctions can be highlighted when they come up.
|
# ? Jul 21, 2010 14:50 |
|
Vanadium posted:We could deport them to the coding horror thread
|
# ? Jul 21, 2010 15:17 |
|
I may have an application for Automatic Differentiation. I'm starting to look at FADBAD++ and CppAD. Are there other packages that are clearly better? Any other wisdom? http://www.fadbad.com/fadbad.html http://www.coin-or.org/CppAD/
|
# ? Jul 21, 2010 16:16 |
|
Warning: C++ newbie I'm looking ahead to something we'd like to implement in our C++ desktop app in about a month. We're partnering with a GPS truck-tracking company which will be sending positional updates at regular intervals. Each update will be POSTed via HTTP from their system(s) to our app, at an address of our choosing (eg. http://the-machine-our-app-is-running-on/truckUpdate). I see two ways of processing this HTTP request. 1) Package a lightweight web server (like BadBlue or Tntnet) within the app. When a request comes in, the app can deal with it on the fly. 2) Use some other web server (apache+mod_python, apache tomcat, etc) on the same machine to listen for requests, and dump data into an intermediate container (plaintext/json/xml files, or some RDBMS). The main app would then poll the container for new data regularly. The data being received is not mission critical, so the delay presented in #2 is probably acceptable (poll the container every half-minute or so). What I don't know much about is what's involved in #1, and if it's considered a Bad Idea (tm) in general to expose a responsive desktop app in this way. Any comments/suggestions? Edit: I realize this isn't a programming question per se, I just want to flush out any obvious "WHY would you even THINK of doing this in C++ you IDIOT" points. epswing fucked around with this message at 16:46 on Jul 21, 2010 |
# ? Jul 21, 2010 16:37 |
|
BigRedDot posted:There, are worse things than straight C. For instance, the horrible melange that my coworkers produce is real, actual "C/C++", or as I prefer to call it: "C-". C-, why haven't I thought of that before? I need to remember to use that one FWIW, hohum, I think a separate C thread could be interesting, granted there's enough interest to get it going...
|
# ? Jul 21, 2010 17:46 |
|
Zerf posted:C-, why haven't I thought of that before? I need to remember to use that one In my opinion, there is not enough to separate the two languages to bother with two threads. It would just add another thread I have in my bookmarks which never gets little to/no traffic. In addition, people randomly coming to ask questions would probably end up asking here since the C++ one is likely to be the first one they see.
|
# ? Jul 21, 2010 18:11 |
|
How about "C++ but maybe also C Programming Questions Not Worth Their Own Thread" FWIW I think one thread is adequate, even if I do hate the sight of "C/C++"
|
# ? Jul 21, 2010 18:17 |
|
BigRedDot posted:How about "C++ but maybe also C Programming Questions Not Worth Their Own Thread" Yet most recruiters / headhunters expect to see it that way on resumes.
|
# ? Jul 21, 2010 18:27 |
|
HFX posted:Yet most recruiters / headhunters expect to see it that way on resumes. I guess? Mine has said "C and C++ on Unix platforms" for the last 15 years and I've somehow managed to get offers.
|
# ? Jul 21, 2010 18:37 |
|
Is there a good way to sort of do a form of reflection in C++ and find address of a method by name at run time and call it? What I would like to do is to find address of a member method of a certain class by name and call it on an instance that I already have. I suppose I would need a cross-platform library that is able to read symbols from an executable/shared library at run time and then I would also have to deal with name mangling and virtual tables?
|
# ? Jul 21, 2010 18:55 |
|
Crazy RRRussian posted:Is there a good way to sort of do a form of reflection in C++ and find address of a method by name at run time and call it? What I would like to do is to find address of a member method of a certain class by name and call it on an instance that I already have. I may be out of date, but no, there isn't. The 2 major points you bring up in the second part (symbol table format and virtual-table layout) are compiler dependant and getting C++ compiler vendors to stick to some sort of platform-independant standard has been impossible from the looks of history. The whole idea of COM and of interface programming has been the a sort of standardising the community has engineered themselves to try to overcome the problem. It works, but can be a bit messy. Nothing as nice as .Net reflection, but then again, it may be a bit to easy to get in to some C++ functions you shouldn't be going near if C++ "reflection" was that easy PS: Hello thread and fellow bit-jugglers. Nice read. Still got to go through most of the thread yet
|
# ? Jul 21, 2010 19:43 |
|
|
# ? Jun 8, 2024 17:43 |
|
Bandamyion posted:I may be out of date, but no, there isn't. The 2 major points you bring up in the second part (symbol table format and virtual-table layout) are compiler dependant and getting C++ compiler vendors to stick to some sort of platform-independant standard has been impossible from the looks of history. The whole idea of COM and of interface programming has been the a sort of standardising the community has engineered themselves to try to overcome the problem. It works, but can be a bit messy. Pro-tip since you're new to the thread, Crazy RRRussian is a fakeposter who has been around these parts for a while under different names (Hexadecimal, Entheogen, ...)
|
# ? Jul 21, 2010 19:55 |