Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Red Oktober
May 24, 2006

wiggly eyes!



I'm currently getting started in C, by using it to write a compiler of sorts (its for an assignment).

Much of the code is generated already by BNFC (from the grammar I've written) , but I need to edit it to traverse my tree and do stuff.

My question is what is a good development environment to start off in C?

I've been using eclipse for java, but the C version doesn't seem to be as usable.

What would you all recommend?

I'm using Mac OS X, if it matters.

Adbot
ADBOT LOVES YOU

Red Oktober
May 24, 2006

wiggly eyes!



Thanks for the input, I'll probably just stick with doing it manually but using xcode for the syntax colouring.

(My reason for wanting to use an IDE was that the vast amount of generated code was making it tricky to do it by hand, and I'm more concerned about getting this project in than learning C at the minute.)

Red Oktober
May 24, 2006

wiggly eyes!



I'm having a problem which I can't seem to sort out.

If I take a piece of code like this:

code:
case is_Stm:	
        char *str;
	str = (char *)calloc(strlen(visitIdent(_p_->u.stm_.ident_))+2, sizeof(char));
	strcpy(str, "_");
	strcat(str, (visitIdent(_p_->u.stm_.ident_)));
	return str;
    break;
The compile fails, whilst

code:
case is_Stm:	
       [b] printf("\n");[/b]
        char *str;
	str = (char *)calloc(strlen(visitIdent(_p_->u.stm_.ident_))+2, sizeof(char));
	strcpy(str, "_");
	strcat(str, (visitIdent(_p_->u.stm_.ident_)));
	return str;
    break;
Succeeds. It seems to fail whenever I try and declare something at the top of a block of code. Putting a statement like print about that sorts it.

I've tested this by trying to compile simclist into my project as well, and it fails for the same reasons.

Exact error is "error: syntax error before ‘char’" (if char is what I'm trying to declare.)

I'm using gcc 4.0.1, on mac os x leopard.

Any ideas?

Red Oktober
May 24, 2006

wiggly eyes!



Ah, I see. I guess I'll work on keeping everything where it 'should' be, rather than kludging it then.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply