|
I want my CVector to store pointers. However, no matter how much indirection I add, it tries to dereference the variables to perform copy ops on primitive data. How should I structure the CVectorCreate call? code:
code:
code:
|
# ? Feb 25, 2012 06:13 |
|
|
# ? Jun 8, 2024 01:11 |
|
What does your actual call site look like? The problem with simplifying problems to ask other people is that sometimes you simplify them too much and get rid of actually useful detail.
|
# ? Feb 25, 2012 06:18 |
|
Jabor posted:What does your actual call site look like? code:
|
# ? Feb 25, 2012 06:54 |
|
Jam2 posted:
The first thing I'm going to say is that storing a pointer to something allocated on the stack is usually a bug waiting to happen.
|
# ? Feb 25, 2012 07:28 |
|
Jam2 posted:
Is that even legal C? I thought you had to use alloca or something.
|
# ? Feb 25, 2012 08:12 |
|
Suspicious Dish posted:Is that even legal C? I thought you had to use alloca or something. It's valid C99.
|
# ? Feb 25, 2012 08:19 |
|
Jabor posted:The first thing I'm going to say is that storing a pointer to something allocated on the stack is usually a bug waiting to happen. But it doesn't even do that. And when I try to Malloc and store I get the same result. It has to do with the vectors element size
|
# ? Feb 25, 2012 10:07 |
|
Is putting something like "rmask = 0xff000000;" into an unsigned 32-bit integer actually valid?
|
# ? Feb 25, 2012 14:03 |
|
That just about fits, doesn't it?
|
# ? Feb 25, 2012 14:12 |
|
I think so, but VC++ is giving me errors like: - error C4430: missing type specifier - int assumed. Note: C++ does not support default-int - error C2371: 'rmask' : redefinition; different basic types Heres the full block: code:
Chillbro_69 fucked around with this message at 14:20 on Feb 25, 2012 |
# ? Feb 25, 2012 14:17 |
|
Sounds like you're trying to put expressions (assignments) into the top-level scope. You can initialise variables as you're declaring them, but you can't declare them and then assing to them.
|
# ? Feb 25, 2012 14:19 |
|
Vanadium posted:Sounds like you're trying to put expressions (assignments) into the top-level scope. You can initialise variables as you're declaring them, but you can't declare them and then assing to them. Yep, that was it. Thanks
|
# ? Feb 25, 2012 14:23 |
|
Does anyone know of an easy to use library or other reusable code, written in C or C++, that can take a human-readable function or type name and mangle it using gcc's ABI, respecting all of the shortcuts and substitutions defined there? Ideally I'd like something like this: code:
|
# ? Feb 25, 2012 14:58 |
|
Flobbster posted:Does anyone know of an easy to use library or other reusable code, written in C or C++, that can take a human-readable function or type name and mangle it using gcc's ABI, respecting all of the shortcuts and substitutions defined there? I think GNU binutils has demangle.h which can go in both directions.
|
# ? Feb 25, 2012 16:34 |
|
litghost posted:I think GNU binutils has demangle.h which can go in both directions. Hmm, I dug through the binutils source and didn't see anything in demangle.h that indicated that it did mangling as well as demangling (except for a random function to mangle an operator name). I was hoping this was already a solved problem since (1) I don't want to have to dig through gcc's source code, and (2) gcc's mangling is probably based on ASTs anyway rather than the text representation of the function declaration. I feel like I'm going to be forced to implement a small function prototype parser and do the mangling myself if I want to do this.
|
# ? Feb 26, 2012 14:00 |
|
If you consider function argument types defined via template metaprogramming, you are gonna have to implement a frighteningly large part of C++ for that. Or even something like void f(int (&)[sizeof(FILE)]);
|
# ? Feb 26, 2012 14:12 |
|
Vanadium posted:If you consider function argument types defined via template metaprogramming, you are gonna have to implement a frighteningly large part of C++ for that. Or even something like void f(int (&)[sizeof(FILE)]); Yeah, yuck. For now I'd be happy with supporting simple global functions and class methods/ctors/dtors, where your arguments wouldn't be more involved than primitives, some STL classes, and user defined data types. This is intended to be part of a library of support code for intro C++ courses, where students wouldn't be defining anything too bizarre.
|
# ? Feb 26, 2012 14:42 |
|
If its part of a course just use the hack-OO C way...code:
|
# ? Feb 26, 2012 17:57 |
|
Paolomania posted:If its part of a course just use the hack-OO C way... Absolutely not This isn't student-facing code anyway -- I'm doing things to make certain runtime analysis of student code easier, and I'm trying to eliminate the step where I have to run "nm" to get the mangled names first. I've decided to just write a simple parser for now -- 99% of the cases I'm working with involve basic arguments, so writing mangle("foo(int, const char*)") and getting back "_Z3fooiPKc" is pretty easy to whip up. If and when I decide I need it, I'll just snag the appropriate part of the C++ grammar and build a parser from that, which should cover just about all the behavior someone in my position might need (as long as they stay away from horrible examples like Vanadium's).
|
# ? Feb 26, 2012 18:35 |
|
Ah, I thought this was for pedagogical reasons. I like the idea of first teaching someone how to structure a class without the compiler enforcing it. That way when you show them C++ syntax it impresses upon them what the compiler is actually doing and why it makes their life easier.
|
# ? Feb 26, 2012 19:35 |
|
If I wanted to make a drawing area or viewer inside of a GTK+/GTKmm window, what library might be the best bet to use?
|
# ? Feb 27, 2012 23:00 |
|
Flobbster posted:If and when I decide I need it, I'll just snag the appropriate part of the C++ grammar and build a parser from that, which should cover just about all the behavior someone in my position might need (as long as they stay away from horrible examples like Vanadium's). You seem to be unaware of how complicated the C++ grammar really is. You could always shell out; that may be the most practical option.
|
# ? Feb 27, 2012 23:06 |
|
Hurricane human being posted:If I wanted to make a drawing area or viewer inside of a GTK+/GTKmm window, what library might be the best bet to use? GtkDrawingArea?
|
# ? Feb 27, 2012 23:11 |
|
Okay this is kind of specific, hopefully someone can help. I'm currently taking a CUDA optimization course (CUDA being an NVIDIA GPU). Code is written in C/C++. Things are currently set up such that we can access the hardware and compiler remotely via ssh - this way we are not forced to go into a computer lab (remember the code is programmed for / compiled to / must be run on the CUDA hardware). The only thing is its a pain in the rear end using ssh for doing coding (duh). I'm trying to wrap my head around how to write the code locally, and just somehow upload it, but it doesn't seem like there's an obvious way to do it. I guess I could look into local compilation and running it on an emulator of some sort to test it prior to uploading it to my school's linux network. *sigh* I dunno. This is probably too specific for here, but its worth a shot.
|
# ? Feb 27, 2012 23:46 |
|
sounds like a great time to learn how to use vim
|
# ? Feb 27, 2012 23:49 |
|
Or X forwarding.
|
# ? Feb 28, 2012 00:20 |
|
if you can use ssh, you may e able to use scp or sftp.
|
# ? Feb 28, 2012 00:39 |
|
OddObserver posted:if you can use ssh, you may e able to use scp or sftp. Almost certainly. If he's running windows locally, there's a few alternatives that can work with that, e.g. komodoEdit. (I used kate from kde4/windows last time it came up, but that's honestly only recommended for the kind of people that happen to already have it installed.)
|
# ? Feb 28, 2012 01:51 |
|
floWenoL posted:You seem to be unaware of how complicated the C++ grammar really is. No, actually I'm totally aware of it, which is why I'm avoiding having to exercise that option as long as possible. I would only need a reasonable subset of valid function headers, and I'm not terribly concerned with esoteric cases -- people using my library wouldn't be plugging in functions that take templated pointer-to-member arguments with const volatile modifiers or anything like that. ...which is why the very rudimentary tokenizer I wrote is doing the job just fine so far, anyway.
|
# ? Feb 28, 2012 02:12 |
|
What was that legitimate and cool thing you were doing, again?
|
# ? Feb 28, 2012 02:45 |
|
Computer viking posted:Almost certainly. If he's running windows locally, there's a few alternatives that can work with that, e.g. komodoEdit. (I used kate from kde4/windows last time it came up, but that's honestly only recommended for the kind of people that happen to already have it installed.) Can you elaborate on this a bit?
|
# ? Feb 28, 2012 03:11 |
|
Cyril Sneer posted:The only thing is its a pain in the rear end using ssh for doing coding (duh). I'm trying to wrap my head around how to write the code locally, and just somehow upload it, but it doesn't seem like there's an obvious way to do it. There's a whole bunch of ways if you're on Linux: - remote-mount the entire remote system over SSH; edit the files locally, as you would anything else on a networked drive - use git or another DVCS that supports SSH, possibly with a post-commit hook to automatically upload your changes - use rsync or, failing that, scp to upload your changes before compilations - install Dropbox on both systems, use that - use an editor with built-in sshfs support (I can't name any offhand but I'm pretty sure they exist) If you're on Windows, it's a bit uglier - mounting the system over SSH isn't an option, and while windows ports of most of these tools exist they often aren't as pleasant to install or use. In that case, dropbox or an editor with sshfs support are probably your best bets. If you're on OSX I have no clue.
|
# ? Feb 28, 2012 07:49 |
|
I've used sshfs for OSX, it was a little rough but that was a couple years ago. Dokan is a userspace filesystem for Windows that claims to have sshfs. Just found that by searching, so I dunno if it is any good. It could also be an excuse to learn vim.
|
# ? Feb 28, 2012 07:55 |
|
pseudorandom name posted:What was that legitimate and cool thing you were doing, again? I don't want to give away all the details because I'm planning to do get a conference publication or two out of this But basically, we do a lot of automated grading of assignments in CS classes, and students aren't always good about declaring their functions correctly (get the parameters wrong, or name it wrong, stuff like that). If an instructor writes a test harness that links directly to the student's code and functions are missing, it won't even compile and the student gets less than ideal feedback. If the assignment includes 10 functions and the student messed up on one of them, I want to be able to give them feedback for the other 9, instead of having compiler/linker errors kill the whole thing. So what I want to be able to do instead is look at the exported symbols of the executable and dynamically load the functions, and wrap that in a nice API that instructors can use. (Essentially a weak kind of reflection.) I've already got it working if I give it the mangled name directly, so I'm just trying to improve the API at this point.
|
# ? Feb 28, 2012 14:58 |
|
ToxicFrog posted:There's a whole bunch of ways if you're on Linux: OS X options are basically the same as linux in this case. Thirding vim. This is the biggest advantage of vim in my opinion and it's not all that hard to learn the basics. Honestly, if you're on windows, you'd be better off installing a Linux VM to access the remote machine just because it gives you more options. (Assuming you don't want to spend the time to learn vim)
|
# ? Feb 28, 2012 19:56 |
|
If you're on Windows and the remote store has SCP or SFTP, then WinSCP has a "keep up to date" feature that keeps a local and remote folder in sync.
|
# ? Feb 28, 2012 20:55 |
|
I'm looking for recommendations for a performance analysis tool. For some reason our apps are having trouble working with PGPROF, and so I've been asked to investigate alternatives. Does anyone have one that they have had favorable experiences with that I can look into? My general requests being only that it profiles C++ and handles multiple threads well.
|
# ? Feb 28, 2012 21:03 |
|
I'm writing a program in C++ that passes some pointers around that I really don't want modified, some I'm doing the const int* const* blah blah thing. Then I noticed that I can writecode:
|
# ? Feb 29, 2012 03:47 |
|
Zakath posted:I can write That is assigning to what the value true if boolPtr is not NULL, and false if boolPtr is NULL. That is, your code's equivalent to code:
This has nothing to do with your use of const pointers, so I'm not sure why you're including that information in your question.
|
# ? Feb 29, 2012 03:58 |
|
|
# ? Jun 8, 2024 01:11 |
|
shrughes posted:That is assigning to what the value true if boolPtr is not NULL, and false if boolPtr is NULL. That is, your code's equivalent to Is there any way of checking for this kind of undesired assignment?
|
# ? Feb 29, 2012 04:24 |