|
Red Oktober posted:I'm currently getting started in C, by using it to write a compiler of sorts (its for an assignment). Pretty much the only choice you have is Xcode, which is free once you sign up for a developer account on Apple's site (also free). You can also probably find it on your OS X install disc.
|
# ¿ Mar 1, 2008 02:40 |
|
|
# ¿ May 4, 2024 02:36 |
|
more falafel please posted:For a simple project with a few source files, a Makefile would look like this: What about a project with 40 source files and multiple targets? At some point you just want to let the computer take care of it.
|
# ¿ Mar 1, 2008 19:29 |
|
citsejam posted:If I disable certain signals in a parent process with sigignore, will I be able to use them in a child process if I use sigset to re-enable them in the child's code? That should work, yes. fork() gives the new process an independent signal mask (initialized to the current value of the parent's). At least, that's how it works in posix- I don't have a manpage for "sigignore" so I assume you're on something else. haveblue fucked around with this message at 02:50 on Mar 2, 2008 |
# ¿ Mar 2, 2008 02:47 |
|
Thug Bonnet posted:No, that's what I'm asking! I'm just kind of curious, honestly. But how would the program know "where it is" in memory, how large it is, etc. Also, I assume it's not necessarily contiguous.. Each process's address space is identical*, so that information isn't really useful to anything other than the kernel. If such a query existed, it would return identical results for all processes on the computer. A program generally doesn't have or need the ability to know what physical addresses its virtual pages are at, especially because those may change literally from instruction to instruction under a modern virtual memory system. *Unless ASLR is enabled, but again, that's only the OS's concern.
|
# ¿ Mar 10, 2008 21:27 |
|
Entheogen posted:I believe the OS allocates a chunk of RAM to the program and maps it using virtual memory. That is for program the memory may start at 0x0000 or something but then OS maps it to real memory. I am not quite sure. Pretty much. Null, the stack, the default heap, and the application code all tend to show up at the same (virtual) address for all programs. The locations of loaded libraries are the same for each launched instance of a linked binary (but may be different for other, different programs). Incidentally, this is what allows buffer overflow exploits to work and be portable- the locations of parts of the process image can be predicted across systems (and it's what ASLR is designed to break). quote:I think for C++ programs "how large it is" can grow as the program continues to allocate new memory on heap, so the OS must be adding to its virtual page. I know for java you have to actually set a maximum amount of heap memory you will use, but not for C++. The largest possible address depends on which system you're on. On Win32 you get 2GB of virtual space; the largest valid pointer value is UINT_MAX/2. On 32-bit OS X and other Unixes you get somewhere between that and 4GB. On a 64-bit architecture the limit is so high it's not worth calculating. haveblue fucked around with this message at 22:39 on Mar 10, 2008 |
# ¿ Mar 10, 2008 22:35 |
|
xobofni posted:Really stupid question here about pointers in C. The first code copies the string constant into the variable-sized array a, the second creates a pointer to the string constant before attempting to change it. These compiled-in constants are read-only by default; if you're using GCC there's a flag you can use to allow writing to them.
|
# ¿ Mar 11, 2008 21:45 |
|
Optimizations and debugging are pretty much mutually exclusive; the compiler will tie your code in knots behind the scenes. Especially if it uses aggressive inlining.
|
# ¿ Mar 13, 2008 05:02 |
|
Yeah, sorry, I meant that its size was determined at compile-time rather than typing-time.
|
# ¿ Mar 15, 2008 22:08 |
|
very posted:A friend of mine thinks that the memory where function addresses are stored is getting clobbered somehow. Is that even possible? Would VC++ just let me do that? I put the code that breaks at the very beginning of my program and stepped through it with no other threads running, but it still goes to the wrong function. It wouldn't *knowingly* let you do that (not in C++, at least), but it can certainly get corrupted. What relationship, if any, does the wrong function have with the correct one? Also, double-check the type of the pointer you're using to invoke the method.
|
# ¿ Mar 18, 2008 17:30 |
|
graffin posted:I'm using it in C++, in the context of a template for a binary tree based dictionary. The object is an element in a node. In the dictionary, I'm trying to test the element to determine if it is an int or string. C++ doesn't have any facility for determining what basic type a symbol is, RTTI only works on classes. Also, if your template class has to implement different functionality based on the type of the varying element, you may want to revisit its design.
|
# ¿ Mar 20, 2008 20:05 |
|
That error means that there is no main function anywhere that gcc can find. It's trying to produce an executable and can't figure out where your code takes over once the process is created. Where is main? Is there a path of includes leading to it from deck.cpp? If you want to produce an object file for linking later you have to use a different invocation of gcc.
|
# ¿ Mar 23, 2008 02:42 |
|
I disagree. The author should determine dependencies and set them in stone once; the users should be able to bypass those just as they're bypassing whatever issues and complexities prompted them to use pre-existing code to address in the first place. vvvvvvvv Uninitialized pointers? haveblue fucked around with this message at 22:37 on Mar 26, 2008 |
# ¿ Mar 26, 2008 22:30 |
|
TSDK posted:TSDK's Law: Everyone is an idiot. Yeah, but you wouldn't think that for someone with his resume that topic would be C.
|
# ¿ Mar 27, 2008 18:15 |
|
fret logic posted:Where's a good place to start for programming simple graphics in C? Nothing fancy, just lines or pixels to get me started. I've tried to decipher the source code for nethack, as far as how they print the ASCII characters in different places, and it's a bit above me heh. Manipulating a character display the way NetHack does isn't really the same as "lines or pixels". The best way to quickly make something appear on the screen is probably OpenGL with GLUT. A program that opens a window and draws some simple shapes can come in under 30 lines. Once you're comfortable with that, you can leave GLUT behind to do your own context setup, and you're off and running.
|
# ¿ Apr 1, 2008 01:37 |
|
TurtleBoy posted:I am looking into programming a game and I had a question which google is proving useless to answer, possibly because I am asking it the wrong questions. The best way to implement it is zlib; the data files are just compressed directory trees. You won't be able to stop people from taking the art if they really want it, so you may as well save yourself some work.
|
# ¿ Apr 1, 2008 18:56 |
|
xgalaxy posted:Can anyone recommend any good books on compiler / interpreter / language theory, lex and yacc, etc? Compilers: Principles, Techniques, and Tools, aka the Dragon Book, is the gold standard.
|
# ¿ Apr 6, 2008 07:38 |
|
Is your header protected by #ifdefs? That error means that the compiler passed over the same declarations twice.
|
# ¿ Apr 7, 2008 04:23 |
|
...this is the thread for answering programming questions. Is that process really so complicated? Yes, it's almost certainly the lack of that that is causing the problem. There's a point in your code where airport.h can be reached through two different include statements (one to airport.h itself, one to another file that also includes airport.h), so the compiler thinks it's been defined twice. haveblue fucked around with this message at 05:19 on Apr 7, 2008 |
# ¿ Apr 7, 2008 05:16 |
|
The OS X 10.5 manpage for fflush makes no mention of input streams; it only says the function will fail if the stream is "not open for writing".
|
# ¿ Apr 11, 2008 19:36 |
|
6174 posted:Would a function pointer to a swap routine be reasonable? If needed I can restructure things to make this easier. This would be quite reasonable. You'd have the indices as its parameters and just have it perform the same swap on any of an arbitrary set of arrays. quote:Can anyone point me in the right direction? You need the struct keyword before the type of the parameter (or a typedef statement for the structure definition). haveblue fucked around with this message at 22:24 on Apr 14, 2008 |
# ¿ Apr 14, 2008 22:22 |
|
almostkorean posted:Can someone tell me why this doesn't work? Well, first, atof expects a string, not a single char (and it expects a null terminator, so don't just pass it &operand). Second, once you get it to run, it's going to crash because you didn't allocate any memory for number to point to.
|
# ¿ Apr 15, 2008 21:35 |
|
Your problem right now seems to be coming up with a way to organize the data you're gathering. Do you know about structures yet?
|
# ¿ Apr 23, 2008 17:19 |
|
Jungle Bus posted:I'm taking my first C class right now, and it's mostly going well, but there's one thing I can't figure out: how do I take keyboard input without waiting for the user to press enter (along the lines of "press any key to continue")? Am I missing something obscenely obvious? getc()
|
# ¿ Apr 23, 2008 23:56 |
|
Drx Capio posted:How else would you implement a 3-Vector? It's called std::vector for a reason, you know! Probably with something that doesn't have a ton of baggage related to dynamic resizing.
|
# ¿ Apr 24, 2008 23:06 |
|
Filling in a 12GB range with unpredictable writes of single bytes? When did he say this project had to be finished by? (And don't forget to throw in a targa header before you start writing pixels.)
|
# ¿ Apr 29, 2008 04:56 |
|
%s expects a char*, not just a char. (Next time, please try to give more information about the crash, at least the line number.)
|
# ¿ Apr 30, 2008 04:25 |
|
Mustach posted:There's not really a "should" here. All of these work for bypassing the struct namespace: When using all except the last, make sure the struct's real name is different from the one created by the typedef.
|
# ¿ May 3, 2008 02:29 |
|
Vanadium posted:Why? To avoid a conflict, that's how I remember learning it v:)v I just tried it and apparently I have been misled all these years.
|
# ¿ May 3, 2008 02:39 |
|
Soldat posted:When I call longprim_check, I just went it to return true if the input is simply 'add1' or 'sub1'. Anything else I want it to return false. Right now it's returning true for everything. What glaringly obvious thing am I missing? The strcmp function and the fact that most of your nested if statements do not have else cases. If you pass "adff" to primcheck_add it's just going to fall out in the middle, returning garbage (which would be interpreted as true unless it was 0). Your compiler should be warning you about this.
|
# ¿ May 8, 2008 22:20 |
|
Looks like numMatches is not getting reset properly either. So it just adds the match onto all the matches from all previous trials.
|
# ¿ May 12, 2008 03:18 |
|
Zombywuf posted:No, but if you're ACKing packets it's usually the better option. But it seems Smackbilly has no say in the protocol so it's moot anyway. Lots of games using UDP with a very thin reliable layer on top of it. It can be tweaked to better match their traffic patterns (small packets, no bulk transfers, compensation for loss at the application layer) than TCP. vvvvvvvv Considering the subject, your analogy should be reversed haveblue fucked around with this message at 05:26 on May 26, 2008 |
# ¿ May 26, 2008 00:48 |
|
Kei posted:Is sendto() a non-blocking operation? You can explicitly request a nonblocking socket from socket(), which will never block but instead cause socket calls to return an error immediately.
|
# ¿ Aug 25, 2009 20:23 |
|
Avenging Dentist posted:That's basically why they exist. I thought they existed because until very recently compilers were not smart enough to detect good places to generate jump tables automatically and switch was how you explicitly requested one.
|
# ¿ Aug 26, 2009 19:52 |
|
king_kilr posted:I don't know how Clang does on template error messages, but one of the things I've heard, both from Brett Cannon on compiling CPython and from the Ars Technica review of Clang integration in XCode is that the errors are lightyears better. The examples in the Ars review were brilliant. Highlight the exact token it choked on in the editor view? Yes, please.
|
# ¿ Sep 2, 2009 16:01 |
|
Consider that Clang exists largely because it was easier to create a brand new toolchain with a different fundamental design than to add that and various other features to GCC.
|
# ¿ Sep 3, 2009 02:01 |
|
bobbles posted:Question: How can I compile c from the terminal in Snow Leopard gcc gives this... OS X does not install dev tools by default, they may be present on the Snow Leopard DVD or if not can be downloaded from http://developer.apple.com .
|
# ¿ Sep 7, 2009 04:46 |
|
Runaway Five posted:Quick question, is the following okay in a sense it won't cause memory leaks? Why are you using a generic pointer for an object you obviously know the type of?
|
# ¿ Sep 24, 2009 18:54 |
|
That's one of those things that you pretty much need to explain why you're trying to do it so you don't get dismissed out of hand as "that's something that just shouldn't be done". If you're trying to avoid a million search-and-replace operations, you could implement your alternative div with a different name and redirect references to it with a #define (and #undef at the end).
|
# ¿ Dec 28, 2009 18:27 |
|
Like ShoulderDaemon said, that is not guaranteed to stay accurate through manipulation of the executable after the process is created. You can try to apply software protection to it like holding open a file descriptor to your executable but you will still trip over something really crazy and unavoidable like being launched off a network disk which subsequently times out and disappears.
|
# ¿ Jan 13, 2010 22:57 |
|
|
# ¿ May 4, 2024 02:36 |
|
Whilst farting I posted:I understand how translation and rotation work, I think, now - I just don't understand why my code is not working. It'll be a lot easier for me to understand projection matrices though if I can get it moving besides manually changing the x coordinates of the quad. -0.75 is a very small amount for a GL rotation; that number is supposed to be in degrees (and see how the example code uses 72 there). A much larger number is needed for the image to noticeably change.
|
# ¿ Mar 21, 2010 20:18 |