|
Red Oktober posted:I've tested this by trying to compile simclist into my project as well, and it fails for the same reasons. The C grammar doesn't allow it. labeled-statements are composed of labels followed by statements and declarators aren't statements. You've discovered one ramification of this, another is that things like code:
code:
|
# ¿ Mar 3, 2008 03:04 |
|
|
# ¿ May 6, 2024 07:31 |
|
oldkike posted:C and C++ are so weird sometimes. Here's another syntax weirdness: code:
pseudorandom name fucked around with this message at 09:17 on Mar 3, 2008 |
# ¿ Mar 3, 2008 09:14 |
|
timer_create()/timer_settime()/etc. are a whole lot more useful than alarm() or setitimer().
|
# ¿ Sep 10, 2008 10:10 |
|
Otto Skorzeny posted:So does gcc, but at least the latter is kind enough to inform you you're using a deprecated header The got rid of them over a year ago for 4.3.0's release.
|
# ¿ Aug 16, 2009 07:30 |
|
RussianManiac posted:is there an explicit call to make a pthread go to sleep, and a call to wake it up? Yes, many. What are you trying to do?
|
# ¿ Oct 6, 2009 23:07 |
|
Olly the Otter posted:Are you wanting to force a thread to go to sleep with a function call from a different thread, sort of like the Win32 API function SuspendThread? I'm fairly certain you can't do that with POSIX threads. Oh, yeah, if that's what you're trying to do, you're on your own. A quick look at Boehm GC's stop-the-world implementation shows that it stops individual threads using pthread_kill to get them into it's own signal handler that blocks on a semaphore, which seems to be the most portable method.
|
# ¿ Oct 7, 2009 00:15 |
|
teen bear posted:Could someone tell me why that's happening and also what a backtrace and memory map are? The backtrace is a listing of called functions on the stack, in reverse order. The memory map is the layout of memory in your program, which can sometimes be useful for finding problems. Irrelevant problems in your program (all of which are identified if you build with -Wall like you should)
|
# ¿ Oct 10, 2009 05:35 |
|
Dijkstracula posted:Is the C89 standard published in any official capacity online? I can only see places to purchase it from ISO/ANSI. The final drafts are freely available online.
|
# ¿ Oct 23, 2009 23:57 |
|
Rahu posted:Thanks for the help, wasn't aware of that. The default is -std=gnu89, which is ISO C90 plus GCC extensions, including several that ended up in C99.
|
# ¿ Oct 27, 2009 23:55 |
|
mincepiesupper posted:I have a question about debugging vectors: I recently had to change stl header files in order to make the use of the [] operator behave more like at() and tell me when indices went beyond the size of the vector. Is there a way I could have done this without changing the header files? I'm using gcc 4.1. #define _GLIBCXX_DEBUG
|
# ¿ Oct 31, 2009 00:23 |
|
mincepiesupper posted:Will this work with a release build? The code I am having the problem with is not mine, what I've been given to build it with is for release builds only. I've also been told that debug builds don't work but I've not yet tried this to see exactly what 'don't work' means. If you can change <vector> to hack in your own debugging, you have enough to build with the debug version of libstdc++ instead.
|
# ¿ Oct 31, 2009 02:04 |
|
Vanadium posted:Come on, there is a billion IO mechanisms that deal in non-terminated data to begin with, so just use fwrite here. And printf is one of them, so it's not like you have to live without formatted output to make this work.
|
# ¿ Nov 2, 2009 15:21 |
|
Dijkstracula posted:Well, I stand corrected. I mean, building the format string will be a bit of a kludge, but that's minor compared to what I was thinking he'd have to do beforehand. printf("%.*s\n", length, str);
|
# ¿ Nov 3, 2009 00:49 |
|
Thornes posted:I'm trying to write a program in which a bunch of processes(on a linux machine) communicate very simply with a shared integer. No semaphores or any kind of process synchronization is necessary. The problem is I have no idea how to do this and I'm having a hard time finding an easy to understand tutorial. code:
|
# ¿ Nov 3, 2009 23:53 |
|
Thornes posted:Well this looks like a good start so thanks for the quick reply but is there a way to do this without having to deal with a file? mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0); will work if you do it in the parent and use it from fork()ed children. Edit: Alternately, you can use int fd = shm_open("/somefile", O_RDWR|O_CREAT, S_IRUSR|S_IWUSR) instead of open(). And don't forget to ftruncate(fd, getpagesize()) before the mmap(). pseudorandom name fucked around with this message at 00:46 on Nov 4, 2009 |
# ¿ Nov 4, 2009 00:38 |
|
slovach posted:I was trying to wrap my head around function pointers in C and came across something. Depends on the ABI, but it should work just about everywhere with the normal C calling convention.
|
# ¿ Nov 20, 2009 06:46 |
|
Hiyoshi posted:I'm implementing a shell for a class project and like all other shells, when pressing CTRL-C, a new prompt is supposed to appear. That's no problem, but how do I stop ^C from displaying in my program when I press it? bash, zsh, ksh, etc. don't display ^C anywhere when it's pressed, they just display a new prompt. code:
|
# ¿ Nov 28, 2009 02:18 |
|
Nigglypuff posted:maybe im missing something here but surely any function that manipulates words and letters is gonna choke if you call it with a picture? Yes, you're missing something.
|
# ¿ Dec 9, 2009 08:28 |
|
GrumpyDoctor posted:I have a third-party library that, when it does its thing, writes to stdout. I want it to not do this. It seems like I might be able to use freopen somehow, but I don't know how to redirect stdout to nowhere before I execute the library function (I'm on windows, so no /dev/null) and back to what it was afterward, or even if this is the way to go. freopen("\\\\.\\Device\\Null", "w", stdout) might work.
|
# ¿ Dec 19, 2009 05:32 |
|
functional posted:Got it. The magic trick is learning that the sockaddr you get back can be cast to a sockaddr_in if you know it's IPv4. Also, I needed ntohl. And you can determine what type of sockaddr you have by looking at the sa_family field.
|
# ¿ Feb 8, 2010 06:18 |
|
Contero posted:At what value do (single) floats lose integer precision? For IEEE floats, any integer with absolute value less than or equal to 2significand can be represented exactly. So, for 32-bit floats with a 24-bit significand, 224 = 16777216.
|
# ¿ Feb 9, 2010 08:19 |
|
Signals won't result in truncated disk I/O either.
|
# ¿ Feb 9, 2010 09:30 |
|
LockeNess Monster posted:Is the layout in memory same as a struct for a class with both public and private members? That is, if I am reading a class from a file or char buffer or something, can I cast that char buffer to be pointer to class and then have a working instance of that class through that pointer? Yes, but you don't want to do that for other reasons.
|
# ¿ Mar 18, 2010 08:48 |
|
w00tz0r posted:Does anyone know if Microsoft modified struct in_addr in berkeley sockets for their windows 7 implementation? I'm going to guess without looking that S_un is a union of a bunch of different sockaddr types, and the member you're looking for may or may not be inside a struct member of that union.
|
# ¿ Mar 31, 2010 16:47 |
|
w00tz0r posted:For some reason I was interpreting "un" as "unsigned" rather than "union". That makes a lot more sense. And to follow up, there's probably a #define sin_addr S_un.$SOMETHING.sin_addr in a header somewhere.
|
# ¿ Apr 1, 2010 02:04 |
|
Rocko Bonaparte posted:Is it possible to break a string literal up across lines with comments in between? I rarely find a need for this, except when working with regular expressions. I'll show you generally what I want to be able to do: Maybe you should compile it and see what happens instead of posting about it on the internet?
|
# ¿ Jun 28, 2010 01:31 |
|
Maybe one day somebody will invent something nice using initialization lists and we can just do something like Format("{0} {2} {1}\n", {3, "stuff", 2.0f})
|
# ¿ Jul 6, 2010 05:23 |
|
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 |
|
The minimum number of bytes is 1.
|
# ¿ Aug 11, 2010 04:38 |
|
ShoulderDaemon posted:I thought the urgent flag could result in a select indicating data available while there are zero bytes available for a normal read. That may be possible, but I have no idea how urgent/OOB works and I doubt anybody sensible would be using it in new code. edit: Also, Linux has a SO_RCVLOWAT, but that only influences select/poll/epoll/etc. since 2.6.28 or so, before that it'll just make read/recv/etc. block until the low water mark is not met (and select/etc. will return readable for any amount of data). I think Solaris also has a working SO_RCVLOWAT, but everybody else (including Windows) just ignore that socket option. pseudorandom name fucked around with this message at 05:01 on Aug 11, 2010 |
# ¿ Aug 11, 2010 04:59 |
|
That just tells me how reliable network-facing Microsoft products from the late '90s are.
|
# ¿ Aug 11, 2010 05:07 |
|
roomforthetuna posted:tldr; how do you make a program crash-dump info in a form that can be turned into a file and line number (and ideally but not necessarily also stack trace)? http://code.google.com/p/google-breakpad/
|
# ¿ Aug 23, 2010 00:35 |
|
Member-wise assignment, although there's nothing stopping to from just doing a memcpy() if it can get away with it. (Hooray for the "as-if" rule!)
|
# ¿ Aug 28, 2010 02:32 |
|
You are probably using stack memory after it has been freed (after the function has returned), and the printf() call is overwriting that memory with it's own state.
|
# ¿ Aug 30, 2010 19:08 |
|
Well, that's terrible advice.
|
# ¿ Sep 14, 2010 16:59 |
|
Won't a stack wrapping a vector push/pop from the front of the vector? And require the equivalent of big memmove() for every operation? edit: Nope, it uses push_back(). You learn something new every day. pseudorandom name fucked around with this message at 19:57 on Sep 14, 2010 |
# ¿ Sep 14, 2010 19:53 |
|
And you have to keep in my that whomever is sending the message could be lying about the buffer size.
|
# ¿ Sep 18, 2010 19:28 |
|
Getting the source file and line number information would require interpreting the DWARF information, which is much more involved than just figuring out which dynamic symbol (probably) contains the address.
|
# ¿ Sep 29, 2010 19:41 |
|
libbfd doesn't have an ABI, either, which will make your life difficult when you upgrade. (It exists purely to share code between the various components of binutils, not to provide a public library. Not that that stops people from using it anyway, and causing much suffering.)
|
# ¿ Sep 29, 2010 20:13 |
|
|
# ¿ May 6, 2024 07:31 |
|
http://codepad.org/TuWkRENh
|
# ¿ Sep 30, 2010 10:19 |