View Single Post
  #3   Spotlight this post!  
Unread 01-25-2010, 09:44 PM
nabioullinr nabioullinr is offline
Registered User
FRC #1073
 
Join Date: Jan 2010
Location: Hollis, NH
Posts: 17
nabioullinr has a spectacular aura aboutnabioullinr has a spectacular aura aboutnabioullinr has a spectacular aura about
Re: Cannot Mix C Code

Quote:
/* ScriptParser.cpp*/
#include <string>
#include <cstdio>
#include "ScriptParser.h"
extern "C" {
#include "tiny_scheme_interpreter.h"
}

bool ScriptParser::init(string initFile) {
FILE *fscript;

printf("Initializing TinyScheme...");
scheme_init(&sc);
puts("Done");
...
}
Code:
/* tiny_scheme_interpreter.h */
...
int scheme_init(scheme *sc);
...
Code:
/* tiny_scheme_interpreter.c */
...
int scheme_init(scheme *sc) {
 return scheme_init_custom_alloc(sc,malloc,free);
}
...
I checked the build properties and found that .c and .cpp files are compiled with the same flags but a different variable/macro is used (%ccompilerprefix% and %cppcompilerprefix%) in the command.
Code:
echo "building $@";%ccompilerprefix% $(TOOL_PATH)ccppc %DebugModeFlags% %ToolFlags% $(ADDED_CFLAGS) %Includes% $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL   $(DEFINES) -o %OutFile% -c %InFile%

$(CC_ARCH_SPEC) -ansi  -Wall  -MD -MP -mlongcall
Code:
echo "building $@";%cppcompilerprefix% $(TOOL_PATH)ccppc %DebugModeFlags% %ToolFlags% $(ADDED_CFLAGS) %Includes% $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL   $(DEFINES) -o %OutFile% -c %InFile%

$(CC_ARCH_SPEC) -ansi  -Wall  -MD -MP -mlongcall
I checked the console output and the function definitely seemed mangled...any ideas on howto change compilation to C?

Last edited by nabioullinr : 01-25-2010 at 09:49 PM.
Reply With Quote