Jump to content
Sign in to follow this  
kuyars

Duplicate Global Var?

Recommended Posts

Hi, Im having some problems with my code. Im using the newly released sourceboost with boostC. It was compiling fine with the c2c-plus compiler before and I just made some minor changes.

 

It actually does say that BoostC compiled it successfully, but the linker says that there's a "Duplicate Global Var: " but nothing after the colon. I'm looking at my code and really cant see any instance of any possible global var. Any possible leads would be appreciated, thank you!

Share this post


Link to post
Share on other sites

You need to post some code that illustrates the problem and maybe notes how to reproduce it. Otherwise it's very difficult to say what may be wrong.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Sure, thank you for the quick replies! I'll post my code below. Just a note, it's very messy and inefficient. Im just trying out new ideas and such. This is actually based on some code for a propeller clock that I found linked somewhere on this website. I'm just toying with it for now. Sorry for the mess.

 

It compiles fine, however, the linker seems to give that "Duplicate GLobal Var" error that I spoke of earlier. Thank you.

 

=======================================

 

#include <system.h>
#include <boostc.h>

#define DELAY 47

void initialize();
void do_delay();
char parse_string(char);
void synchronize();
void outpu_letter();
void draw_border_line();
void display_scroll();
void display_fixed();

const char characters[]= 
{
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,    // ' ' 0
0xFF,0xDF,0xAB,0xAB,0xAB,0x87     // 'a' 1
};

const char *string = "        test string1        #";
//const char *string = "test string2";

void initialize()
{
   clear_bit(intcon,GIE);
   clear_wdt();
   set_bit(status, RP0);
   trisa = 0x10;
   trisb = 0x00;
   clear_bit(status, RP0);
   porta = 0x08;
   portb = 0xFF;
}

void do_delay()
{
   char count;
   
   for(count = 0; count < DELAY; count++)
   {
       nop();
   }
}

char parse_string(char index)
{

char *temp_string;

temp_string = string;

switch(temp_string[index])
{
 case ' ': 
	 return 0;
 case 'a':
	 return 1;
 case 'b':
	 return 2;
 case 'c':
	 return 3;
 case 'd':
	 return 4;
 case 'e': 
	 return 5;
 case 'f':
	 return 6;
 case 'g':
	 return 7;
 case 'h':
	 return 8;
 case 'i':
	 return 9;
 case 'j': 
	 return 10;
 case 'k':
	 return 11;
 case 'l':
	 return 12;
 case 'm':
	 return 13;
 case 'n':
	 return 14;
 case 'o': 
	 return 15;
 case 'p':
	 return 16;
 case 'q':
	 return 17;
 case 'r':
	 return 18;
 case 's':
	 return 19;
 case 't': 
	 return 20;
 case 'u':
	 return 21;
 case 'v':
	 return 22;
 case 'w':
	 return 23;
 case 'x':
	 return 24;
 case 'y': 
	 return 25;
 case 'z':
	 return 26;
 case '0':
	 return 27;
 case '1':
	 return 28;
 case '2':
	 return 29;
 case '3':
	 return 30;
 case '4':
	 return 31;
 case '5':
	 return 32;
 case '6':
	 return 33;
 case '7':
	 return 34;
 case '8':
	 return 35;
 case '9':
	 return 36;
 case '#':
	 return 255;
 default:
	 return 0;
}
return 0;
}

//Synchronize with the port A pin 4 which takes in the clock
//information from the AC voltage coming in
void synchronize()
{
char input;

while (!((porta>>3) & 0xFF));
   
   input = ((porta>>3) & 0xFF);
   
   while (input == ((porta>>3) & 0xFF)) 
   {
 //output_port_b(11111111b);
 portb = 0xFF;
}
}

void output_letter(char index)
{
   char fixed_index,count;
   
   fixed_index = index * 6;
   for(count = 0; count < 6; count++)
   {
 //display the corresponding character in the character table on the LED array
 //output_port_b(characters[count + fixed_index]);
 portb = characters[count + fixed_index];
       do_delay();
   }
   //clear all the LEDs
   //output_port_b(11111111b);
   portb = 0xFF;
   do_delay();
}

void draw_border_line()
{
   //output_port_b(00000000b);
   portb = 0x00;
   do_delay();
//output_port_b(11111111b);
portb = 0xFF;
}

void display_scroll()
{
   char line_width = 0, text_index = 0, count = 0, string_num = 0;

   while(1)
   {
 synchronize();
       
       //output_port_b(11111111b);
       portb = 0xFF;
       
       //this creates the speed of the scrolling text
       
       for(count = 7; count > line_width; count--)
       {
	 do_delay();
 }

       //display the characters in the string
       
       for(count = 0; count < 8; count++)
       {
	 output_letter(parse_string(count+text_index));
 }

       //increment the line width to reflect the current position
               
       line_width++;

       //check if the current line width is at the max circle spacing.
       //If so, reset the line width and increment the index into the
       //text string
       
       if(line_width == 8)
       {
	 line_width = 0;
           text_index++;
           if (parse_string(text_index) == 255)
           {
   text_index = 0;
	 }
       }
       
 draw_border_line();
    }
}

void display_fixed()
{
   char count = 0;

   while(1)
   {
 synchronize();
       //output_port_b(11111111b);
       portb = 0xFF;
       
       //display the characters in the string
       
       for(count = 0; count < 7; count++)
       {
	 output_letter(parse_string(count));
 }
 
 //output_port_b(11111111b);
 portb = 0xFF;
    }
}

void main()
{
//initialize the PIC
initialize();

//run the display_loop() function that repeats the scrolling string indefinitely	

display_scroll();

//display_fixed();
}

Share this post


Link to post
Share on other sites

You should never include boostc.h into your code. It is already included via system.h

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Thank you, I just removed it, but the same linker error appears with the following messages:

 

BoostC Optimizing C Compiler Version 1.0 Alpha (for PIC16 architecture)
Copyright(C) 2004 Pavel Baranov
Copyright(C) 2004 David Hobday


success
BoostLink Optimizing Linker Version 1.0 Alpha
Copyright(C) 2004 Pavel Baranov
Copyright(C) 2004 David Hobday
Duplicate global var:

Failed
Exit code was -1.  [No error.]
Removing target: prop.hex
Failed to locate output file 'prop.hex'
Done

Failed

Share this post


Link to post
Share on other sites

Look slike the problem is in line:

const char *string = "        test string1        #";

I will check this. Meanwhile move pointer initialization outside the global scope.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

I want to add that even when this problem gets fixed it's still not a good idea to declare a global string as this memory will be occupied forever (of course 'forever' in terms of program run). It's better to either use 'rom' storage specifier when it's implemented:

 

rom char *ptr = "blah-blah";

 

or declare string inside function as than compiler will reuse memory occupied by the string. In the code below both strings will share same data memory:

 

...
foo( "test" );
foo( "data" ); 
...

 

Regards,

Pavel

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...