thiemann 0 Posted November 18, 2004 Report Share Posted November 18, 2004 Bug description: The linker produces an error if the following code is compiled and linked. Steps to reproduce: 1.) Create a new project 2.) Add a main.c file to the project with the following code inline void serialSendChar(char value); void DoThis() { serialSendChar('a'); } void serialSendChar(char value) { } void interrupt() { } void main() { } 3.) Compile and link the project using BoostC 4.) Notice the var not found error. Expected behavior: There should be no linker error. Is the problem 100% reproducible: Yes SourceBoost version: 5.7 Compiler: BoostC Compiler version: 1.7 Alpha OS: Windows XP Comments: None Quote Link to post Share on other sites
Pavel 0 Posted November 19, 2004 Report Share Posted November 19, 2004 Nice spot. An inline function must be declared with a body. Now fixed. Compiler will report an error for inline function declaration without a body. Regards, Pavel Quote Link to post Share on other sites
thiemann 0 Posted November 25, 2004 Author Report Share Posted November 25, 2004 Even with the new 1.7.2 BoostC compiler, the linker generates an error if an inline function definition is located in another c module, but used in another c module. Example: Make a new project with two files (main.c and test.c) In main.c, put the following code: void dothis(); void interrupt() { dothis(); } void main() { dothis(); } In test.c, put the following code: inline void dothis() { } Compile and link the project. Notice that the linker says that dothis() is an unresolved external symbol. FYI: In main.c, I tried using "inline void dothis();" as the function prototype as well, but the compiler says that an inline function must be declared with a body. Quote Link to post Share on other sites
Pavel 0 Posted November 25, 2004 Report Share Posted November 25, 2004 Even with the new 1.7.2 BoostC compiler, the linker generates an error if an inline function definition is located in another c module, but used in another c module. Example: Make a new project with two files (main.c and test.c) In main.c, put the following code: void dothis(); void interrupt() { dothis(); } void main() { dothis(); } In test.c, put the following code: inline void dothis() { } Compile and link the project. Notice that the linker says that dothis() is an unresolved external symbol. FYI: In main.c, I tried using "inline void dothis();" as the function prototype as well, but the compiler says that an inline function must be declared with a body. <{POST_SNAPBACK}> I don't see any problem here. The code is incorrect and an error message is what should happen. At the point where an inline function is uses it should be declared/defined already. A good place for inline functions is a header hile. Regards, Pavel Quote Link to post Share on other sites
thiemann 0 Posted November 29, 2004 Author Report Share Posted November 29, 2004 Pavel, The dothis() is declared before it is used. It is declared as void dothis() in main.c before it is used in the main() function. Its definition is, however, located in another module, test.c, but this should not be a problem as this is a common thing to do. I am not sure what is incorrect about the code. Please let me know what aspect you may be talking about so that I can clear that up. Thanks, Eric Quote Link to post Share on other sites
Pavel 0 Posted November 29, 2004 Report Share Posted November 29, 2004 Pavel, The dothis() is declared before it is used. It is declared as void dothis() in main.c before it is used in the main() function. Its definition is, however, located in another module, test.c, but this should not be a problem as this is a common thing to do. I am not sure what is incorrect about the code. Please let me know what aspect you may be talking about so that I can clear that up. Thanks, Eric <{POST_SNAPBACK}> When an inline function is called compiler puts the body of this function into the place where call was made from. If this inline function doesn't have a body yet compiler has no code to place there. This is a fundamental difference between regular and inline functions. A regular function can have its definition and declaration in different modules but an inline function can't. Regards, Pavel Quote Link to post Share on other sites
thiemann 0 Posted November 29, 2004 Author Report Share Posted November 29, 2004 OK, I see what you are getting at now. Thanks for clearing it up. Eric Quote Link to post Share on other sites
Recommended Posts
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.