|
Paniolo posted:No you pedantic gently caress a 5 character array takes 5 bytes of memory.
|
# ? Jul 7, 2010 01:23 |
|
|
# ? Jun 1, 2024 21:41 |
|
Dijkstracula posted:You responded to somebody who just discovered that C-style strings are just arrays. Being pedantic over leaving room for that mysterious \0 is precisely what you want to be doing. A better way to do that is to link them to the pertinent entries in the comp.lang.c faq imo I'm too lazy to look for pertinent entries so I'll link these instead http://c-faq.com/aryptr/aryptr2.html http://c-faq.com/aryptr/aryptrequiv.html http://c-faq.com/decl/strlitinit.html
|
# ? Jul 7, 2010 03:17 |
|
I'm not sure if this goes here, but it's in C++ so who knows! Basically I am using the windows API to create a clipboard manager of sorts, mostly as a learning utility. Now I can get the foreground window, AttachThreadInput and send the message WM_COPY, but it doesn't seem to work for all windows. I am guess this has to do with how the other program interprets WM_COPY. To get around this I want to grab the original data from the clipboard, send key strokes for ctrl+c, get new data, store it, and put the original data back. This seems like a really bad way of doing this, is there any better way to grab selected text from a window? Messages I have tried, WM_COPY (it inserts into the clipboard), WM_GETTEXT and EM_GETSELTEXT
|
# ? Jul 9, 2010 12:55 |
|
Have you seen this talk? http://www.galois.com/blog/2010/07/09/galois-tech-talk-video-large-scale-static-analysis-at-mozilla/ It seems like it would be interesting for C++ programmers (who aren't already ahead of the game like some people here).
|
# ? Jul 10, 2010 11:16 |
|
I'm having some trouble with a C++ project I'm writing that uses ImageMagick to convert images to different formats. The problem is happening with the system() command. When running in the Netbeans debugger I am getting an error saying the "sh: convert: command not found". But when I run the program from the terminal, everything works fine. example code: system("convert image1.tif image2.jpg"); I have tried to google the problem, but I cannot seem to find the answer. Any idea what I am doing wrong?
|
# ? Jul 11, 2010 22:52 |
|
FearIt posted:I'm having some trouble with a C++ project I'm writing that uses ImageMagick to convert images to different formats. The problem is happening with the system() command. When running in the Netbeans debugger I am getting an error saying the "sh: convert: command not found". But when I run the program from the terminal, everything works fine. NetBeans is probably passing a bad $PATH to your program. Also, you'd almost certainly be better off using the ImageMagick library directly instead of executing the programs yourself.
|
# ? Jul 11, 2010 22:54 |
|
pseudorandom name posted:NetBeans is probably passing a bad $PATH to your program. I manually set the $PATH in NetBeans and everything worked fine! Thank you!
|
# ? Jul 11, 2010 23:22 |
|
pseudorandom name posted:Also, you'd almost certainly be better off using the ImageMagick library directly instead of executing the programs yourself. I saw Alfresco does this from it's Java framework, people make some weird design decisions. I'm guessing said designers or developers never have to use or integrate their output; everyone else knows the less external dependencies the better. Java has it's own graphics API, I'm sure there is some equivalent for ImageMagick already created.
|
# ? Jul 12, 2010 03:10 |
|
shrughes posted:http://www.galois.com/blog/2010/07/09/galois-tech-talk-video-large-scale-static-analysis-at-mozilla/
|
# ? Jul 12, 2010 14:34 |
|
how does #undef work in C/C++ exactly in case of multiple definitions of same name. For example if I have #define FOO BAR #define FOO GAY then do #undef FOO will FOO be empty or revert to BAR? If no, is there a hack to make it have this stack behavior?
|
# ? Jul 13, 2010 21:00 |
|
no
|
# ? Jul 13, 2010 21:19 |
|
Crazy RRRussian posted:how does #undef work in C/C++ exactly in case of multiple definitions of same name. There are two questions raised here. Firstly, why do you want to do that, and secondly, why haven't you stopped doing it yet?
|
# ? Jul 13, 2010 21:30 |
|
MSVC and gcc both support #pragma push_macro and pop_macro that can give you this behavior, but it's not standard C++. Don't use them. I don't know what other compilers, if any, support them. The preprocessor is garbage.
|
# ? Jul 13, 2010 21:30 |
|
The preprocessor is technically turing complete, and since turing complete is more powerful than a push down automata it must be emulatable. Why the gently caress do you need to do this?
|
# ? Jul 13, 2010 21:40 |
|
king_kilr posted:The preprocessor is technically turing complete, and since turing complete is more powerful than a push down automata it must be emulatable. Why the gently caress do you need to do this? Are you sure you're not mixing the preprocessor up with C++ templates? I'm not sure that's entirely true.
|
# ? Jul 13, 2010 21:42 |
|
Jonnty posted:Are you sure you're not mixing the preprocessor up with C++ templates? I'm not sure that's entirely true. Yeah. The C preprocessor is not turing complete.
|
# ? Jul 13, 2010 22:08 |
|
The reason I wanted to do this is to use macros in small sections of code and to ensure that if they were used elsewhere that it is not altered by redefinition and then undef after I am done using it for code generation.
|
# ? Jul 13, 2010 22:38 |
|
Crazy RRRussian posted:The reason I wanted to do this is to use macros in small sections of code and to ensure that if they were used elsewhere that it is not altered by redefinition and then undef after I am done using it for code generation. Oh I didn't see it was you, hexadecimal. My bad.
|
# ? Jul 13, 2010 23:10 |
|
Crazy RRRussian posted:The reason I wanted to do this is to use macros in small sections of code and to ensure that if they were used elsewhere that it is not altered by redefinition and then undef after I am done using it for code generation. Make sure your macro names are unique?
|
# ? Jul 13, 2010 23:16 |
.
|
|
# ? Jul 13, 2010 23:47 |
|
This is perhaps a more generic CS kind of question but what is readily available in C++ is going to do a lot of determine what I end up doing. Sometimes in various languages I run into a situation where I want to be able to readily look something up like with a hash but I also want to be able sort and order the data too. In languages like Perl or Python is go through the trouble of having both a list and a hash that walk along with each other. But I wonder if I should be looking at ordered maps or something else again. Generally is there a good, off-the-shelf data structure in a standard C++ implementation that could do this cleanly and potentially more efficiently? I am particularly looking at STL's map: http://www.cplusplus.com/reference/stl/map/ I wonder generally under the hood if it's efficient to iterate compared to, say, keeping a hash map and a linked list in sync.
|
# ? Jul 14, 2010 05:41 |
|
Rocko Bonaparte posted:This is perhaps a more generic CS kind of question but what is readily available in C++ is going to do a lot of determine what I end up doing. This is obviously not the thread but I noticed you mentioned Python - you might be interested to know that there's an ordered dictionary datatype that's been backported from Python 3 recently. You might even want to look at the source or the discussion surrounding it for tips on lower-level implementation of this sort of thing.
|
# ? Jul 14, 2010 05:47 |
|
Rocko Bonaparte posted:
It's a red-black tree or a comparable data structure (e.g. skip-list). So insertion/look ups, etc., are logarithmic cost, and /sorted/ traversal is linear.
|
# ? Jul 14, 2010 05:52 |
|
Ugg boots posted:Yeah. The C preprocessor is not turing complete. mmm, I thought it was, via recursive includes. If not ignore me
|
# ? Jul 14, 2010 13:41 |
|
OddObserver posted:It's a red-black tree or a comparable data structure (e.g. skip-list). So insertion/look ups, etc., are logarithmic cost, and /sorted/ traversal is linear. Oooh well that's better than I am using already, so I should play around with it at least. Looking at the template for STL's map, I am afraid of a little problem. I like to use pointers as keys, but I don't want to technically key on the address, but rather the value. With an unordered_map, it allows for a overridden hash function, so I could write my own function to hash against the dereferenced pointer instead. For map, I don't see anything that lets me using the value of pointers. The problem will come about if I store something in a map using a key that's a pointer to, say, a string "foo" I allocated some place. Something else later have another string "foo" to look up in the map at a different allocated address. If it maps on the pointers then it won't find it, but if it maps on the string, then I assume I can find it. Is there a standard mapping structure that gives me that override? Edit: I suppose it doesn't matter if there isn't considerable overhead in manipulating strings when adding and removing them from the map. I'm assuming it's more efficient to pass by reference. Rocko Bonaparte fucked around with this message at 16:41 on Jul 14, 2010 |
# ? Jul 14, 2010 16:38 |
|
Rocko Bonaparte posted:For map, I don't see anything that lets me using the value of pointers.
|
# ? Jul 14, 2010 17:03 |
|
I have a subroutine that does a special inversion that I made. I made an object called a "block" that contains a 12 by 12 array of complex <double> data types, as well as some various other pieces of data that specify what kind of block it is. I am trying to pass a 300 by 3 array of these blocks to a subroutine but I am being told that it is being passed not as a block[300][3] but as a block(*)[3], and this creates a segmentation fault. I made a printf right under the initialization that will tell me if it gets past the beginning, but it doesn't.I have another subroutine does a similar passing thing, and it works just fine. So what is the difference between these two? Broken one: code:
code:
|
# ? Jul 14, 2010 17:44 |
|
Lexical Unit posted:I'm not entirely sure I understand your specific issue, but can't you use the Compare policy of std::map? I think I see the problem. The map will sort by key, not value, right? I was hoping to sort by value, but also be able to recall something by a key.
|
# ? Jul 14, 2010 17:50 |
|
I have a Point<T> class that I am doing some debugging on and I've got a data logging macro that I would like to pass Points into and have them print out. Slightly simplified, I want to be able to do this: std::cout << aPoint; and have it print (thePoints'X, thePoints'Y) I tried defining operator char*() for the Point class and it worked the way I intended but I would have to delete the char* somewhere and that doesn't work with my data logging macro. So my questions: 1) is this even a good idea? its would come in very handy if I can make it work 2) is there any way to make my current method work? 3) is there another way to accomplish the same general effect that I am overlooking?
|
# ? Jul 14, 2010 18:37 |
|
Dooey posted:yearning for ostreams code:
|
# ? Jul 14, 2010 18:44 |
|
Thank you! Thats so much easier than all the other things I had tried.
Dooey fucked around with this message at 19:07 on Jul 14, 2010 |
# ? Jul 14, 2010 19:04 |
|
Rocko Bonaparte posted:I think I see the problem. The map will sort by key, not value, right? I was hoping to sort by value, but also be able to recall something by a key. boost::bimap can do that. If you use an unordered_set_of for the keys, and set_of for the values, you will be able to search by key using a hash table, and iterate values in order.
|
# ? Jul 15, 2010 04:13 |
|
litghost posted:boost::bimap can do that. If you use an unordered_set_of for the keys, and set_of for the values, you will be able to search by key using a hash table, and iterate values in order. That's pretty hard core. I'll branch my toy project and try it on that over the weekend. I'm assuming it'll be faster if it can iterate with log(n) complexity.
|
# ? Jul 15, 2010 04:39 |
|
Rocko Bonaparte posted:That's pretty hard core. I'll branch my toy project and try it on that over the weekend. I'm assuming it'll be faster if it can iterate with log(n) complexity. How can you possibly iterate with log(n) complexity? If you are iterating you are visiting every element which is an n operation on the lower bound. You could have n log (n).
|
# ? Jul 15, 2010 05:08 |
|
HFX posted:How can you possibly iterate with log(n) complexity? If you are iterating you are visiting every element which is an n operation on the lower bound. You could have n log (n).
|
# ? Jul 15, 2010 19:08 |
|
what the heck is this. I dunno who Tim is or where Visual Studio is getting this from. slovach fucked around with this message at 05:57 on Jul 16, 2010 |
# ? Jul 16, 2010 05:52 |
|
slovach posted:
Looks like an array of vectors for graphics. The F32 is probably a typedef for 32bit floats in a header file.
|
# ? Jul 16, 2010 05:56 |
|
HFX posted:Looks like an array of vectors for graphics. The F32 is probably a typedef for 32bit floats in a header file. Sorry, I edited the post. I mean... who is Tim and why does he show up. Those are coordinates I basically retyped out of a 3dsmax file. I dunno where Tim is coming from though. slovach fucked around with this message at 06:01 on Jul 16, 2010 |
# ? Jul 16, 2010 05:58 |
|
Am I reading this right? YOU typed a bunch of numbers into an array and VS somehow came up with a comment about a guy named Tim? What on Earth...
|
# ? Jul 16, 2010 06:04 |
|
|
# ? Jun 1, 2024 21:41 |
|
The MSVCRT implementation of the exp function uses an array of coefficients named p which has that comment. Visual Studio must be sharing Intellisense data between the two.
|
# ? Jul 16, 2010 06:09 |