Jump to content
Sign in to follow this  
asmallri

Preprocessor Substitution Problem

Recommended Posts

The precursor is not performing the substition I expected to see. IN the following code segment line #58 is active (has not been commented out)

 

Lines 74 and 75 are functionally identical however line 75 fails to compile

 

 
58 #define	i2c_SSPIF i2c_SSPIF_PIR, i2C_SSPIF_BIT
...
74 clear_bit(i2c_SSPIF_PIR,i2c_SSPIF_BIT);
75 clear_bit(i2c_SSPIF);

 

BoostC Optimizing C Compiler Version 1.6 Alpha (for PIC18 architecture)

http://www.picant.com/c2c/c.html

Copyright© 2004 Pavel Baranov

Copyright© 2004 David Hobday

 

 

line 75: WARNING: Too few arguments for: clear_bit

I2C-lib.c(75): error: missing right paren

failure

Exit code was 1.

Removing target: I2C-lib.obj

Failed to locate output file 'I2C-lib.obj'

Done

 

Failed

Share this post


Link to post
Share on other sites

Preprocessor is ok. That's your code that's wrong. I tried it with MSVC and GCC and both reported an error.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
The precursor is not performing the substition I expected to see. IN the following code segment line #58 is active (has not been commented out)

 

Lines 74 and 75 are functionally identical however line 75 fails to compile

 

 
58 #define	i2c_SSPIF i2c_SSPIF_PIR, i2C_SSPIF_BIT
...
74 clear_bit(i2c_SSPIF_PIR,i2c_SSPIF_BIT);
75 clear_bit(i2c_SSPIF);

 

Note the capital C in the second argument for your define:

58 #define i2c_SSPIF i2c_SSPIF_PIR, i2C_SSPIF_BIT

--------------------------------------------------^

It's lowercase here:

 

74 clear_bit(i2c_SSPIF_PIR,i2c_SSPIF_BIT);

----------------------------------^

 

I wrote some example code with the correct case and it compiles just fine in GCC and Boostc:

#define i2c_SSPIF_PIR 2
#define i2c_SSPIF_BIT 1

int clear_bit(int, int);

#define i2c_SSPIF i2c_SSPIF_PIR, i2c_SSPIF_BIT

void main()
{
       clear_bit(i2c_SSPIF_PIR, i2c_SSPIF_BIT);
       clear_bit(i2c_SSPIF);
}

int clear_bit(int one, int two)
{
       return (one + two);
}

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...