Shop OBEX P1 Docs P2 Docs Learn Events
ICCv7 Compiling problems. — Parallax Forums

ICCv7 Compiling problems.

TJHJTJHJ Posts: 243
edited 2009-04-09 16:42 in Propeller 1
Ok So I am working on makeing the GPS C program that uses defines more compatable. The orginall one that doesnt use defines works fine. So just this one. Ive got to be missing something. Here is where I am at.

I split the file into two files as suggested by Jazzed.

Header File.

// Header file 
 
#ifndef __GPS_DEFINE_PARSER_H_
#define __GPS_DEFINE_PARSER_H_
// Include files
// Have to put variables here....
// defines
// function prototypes
 
#endif


(replace this text with your code)
 
// gpsDefines.c
#include  "gpsParserDefinesHeader.h"
 
//This is where gloabal variables should go. 
 
// function implementation. 
 
 

Ok so here is the problem I have.
It works if I place the variable declarations in the header file, but they can not be static. It returns a list of warnings·

!W Duplicate Symbols _GPSPIN in files gpsParserDefines.o & gpsParserDefinesDemo.o

For each variable I have, but with an _ in front of it.

The file collection is in the attached zip folder duplicateError.

If I make them static by placing a static decleration in front of it, It compiles with no warnings but does not work.

Ok so now if I move them to where they should be in the C file above the funciton implementation.

Static or not static I get a large list of errors of one of each of the two types

!E C:\PROGRA~1\iccv7prop\Projects\ParallaxGps\GpsParser\DEFINE~1\gpsParserDefinesDemo.c(60): undeclared identifier `lat'
!E C:\PROGRA~1\iccv7prop\Projects\ParallaxGps\GpsParser\DEFINE~1\gpsParserDefinesDemo.c(60): type error in argument 1 to `getDeg'; found `int' expected `pointer to char'

This file collection is in the folder idError.



If anyone can take a min to see what I am missing it would be greatly appricated.

TJ

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I owe everyone here a bunch, So thanks again for answering my dumb questions.
Projects. RG500 ECU system. PropCopter. Prop CanSat. Prop Paste Gun.
Suzuki RG500 in a RGV 250 frame.
Bimota V-Due (Running on the fuel injection system)
Aprilia RS250

Comments

  • Brian FairchildBrian Fairchild Posts: 549
    edited 2009-04-09 16:24
    TJHJ said...

    It works if I place the variable declarations in the header file, but they can not be static. It returns a list of warnings
    !W Duplicate Symbols _GPSPIN in files gpsParserDefines.o & gpsParserDefinesDemo.o
    That's the compiler doing the right thing.

    Using 'static' says that the variable is to be invisible outside of the file in which it is defined. Having static variables defined in your header, which then gets included in multiple files, means the compiler will attempt to create two copies of that variable, hence the 'Duplicate Symbols' warning.

    [noparse][[/noparse]EDIT]
    The next thing I notice is that you've got just one .h file. Convention is that every .c file has it's own .h file having exactly the same name except for the file type extension.

    And your line "#ifndef __GPS_DEFINE_PARSER_H_" would normally be "#ifndef GPSPARSERDEFINESHEADER_H" which isn't pretty but is 'conventional'. The convention being that the token name is the same as the filename but in all caps and with the '.' replaced by '_'.

    I'll have a look at the rest once I've loaded it up.

    Post Edited (Brian Fairchild) : 4/9/2009 4:40:24 PM GMT
  • jazzedjazzed Posts: 11,803
    edited 2009-04-09 16:37
    TJ ...

    Declaring a variable or function (a symbol) in a .c file means it is private to that c file. If you want to share a symbol among .c files, it can not be static. Static means something different in C++ ... there it means the symbol is in global name space.

    You have getDeg declared as something that expects a char* but you are passing an int .... The compiler is telling you that you are abusing the API. Either you change the API or your function call needs to change. Sometimes you need to cast a variable to the right type.

    As I mentioned in the other thread, your header file should not include other headers unless you have a good reason.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • Brian FairchildBrian Fairchild Posts: 549
    edited 2009-04-09 16:42
    TJ

    you might find this useful...
Sign In or Register to comment.