This external variable is driving me nuts!! 
Author Message
 This external variable is driving me nuts!!

Hi All,

It is probably something simple I am missing here but it is driving me
crazy. I have a project I am working on that has 4 source files:

Formulas.c
Utilities.c
FirstDose.c
Results.c

In FirstDose.c I have declared a variable (external to any function in that
file) that I would like to share across all four source files:

Double crcl;

In FirstDose.c I set  crcl = CalculateTheCrCl();  CalculateTheCrCl resides
in Formulas.c
The de{*filter*} shows crcl = 96.4432... Which is correct.

In Results.c I have the following code:

Extern crcl;
 static void FillInResults()
 {
     Char textP[7];

     doubleToString(crcl, textP, 2);    //
     setFieldTextFromString (ResultsClCrField, textP);
 }
These two functions within FillInRestults() reside in Utilities.c.
The de{*filter*} shows crcl = 96.4432... Just before dropping into the
doubleToString() function. Once inside doubleToString(), crcl is for some
reason showing up as 16473.

I have used the exact same code for doubleToString() in several other
projects (all consisting of 1 source code file) and it works just fine. What
that heck is wrong here?

Any help is greatly appreciated.

Andy



Tue, 08 Feb 2005 06:37:11 GMT  
 This external variable is driving me nuts!!
On Thu, 22 Aug 2002 22:37:11 GMT, Andy Black

Quote:

>In FirstDose.c I have declared a variable (external to any function in that
>file) that I would like to share across all four source files:

>Double crcl;
>...
>In Results.c I have the following code:

>Extern crcl;

Should be

  extern double crc1;

And it looks like you have "automatic capitalization" turned on in
your newsreader. That's a bad idea when posting C source code - C is
case-sensitive, as I'm sure you know.

-- Mat.



Tue, 08 Feb 2005 06:49:27 GMT  
 This external variable is driving me nuts!!
Duh,

I knew it was something simple like that. Been staring at too long. Haven't
been able to figure out how to turn off auto capitalization in Entourage.

Thanks for the reply,

Andy


Quote:

> On Thu, 22 Aug 2002 22:37:11 GMT, Andy Black

>> In FirstDose.c I have declared a variable (external to any function in that
>> file) that I would like to share across all four source files:

>> Double crcl;
>> ...
>> In Results.c I have the following code:

>> Extern crcl;

> Should be

> extern double crc1;

> And it looks like you have "automatic capitalization" turned on in
> your newsreader. That's a bad idea when posting C source code - C is
> case-sensitive, as I'm sure you know.

> -- Mat.



Tue, 08 Feb 2005 08:56:05 GMT  
 This external variable is driving me nuts!!
<snip>
Quote:
> Extern crcl;

change this to
extern double crcl;

Quote:
>  static void FillInResults()
>  {
>      Char textP[7];

>      doubleToString(crcl, textP, 2);    //
>      setFieldTextFromString (ResultsClCrField, textP);
>  }
> These two functions within FillInRestults() reside in Utilities.c.
> The de{*filter*} shows crcl = 96.4432... Just before dropping into the
> doubleToString() function. Once inside doubleToString(), crcl is for some
> reason showing up as 16473.

> I have used the exact same code for doubleToString() in several other
> projects (all consisting of 1 source code file) and it works just fine. What
> that heck is wrong here?

heh

--
goose
ruse at webmail dot co dot za



Tue, 08 Feb 2005 18:21:34 GMT  
 This external variable is driving me nuts!!

Quote:

> Hi All,

> It is probably something simple I am missing here but it is driving me
> crazy. I have a project I am working on that has 4 source files:

> Formulas.c
> Utilities.c
> FirstDose.c
> Results.c

> In FirstDose.c I have declared a variable (external to any function in that
> file) that I would like to share across all four source files:

> Double crcl;

> In FirstDose.c I set  crcl = CalculateTheCrCl();  CalculateTheCrCl resides
> in Formulas.c
> The de{*filter*} shows crcl = 96.4432... Which is correct.

> In Results.c I have the following code:

> Extern crcl;
>  static void FillInResults()
>  {
>      Char textP[7];

>      doubleToString(crcl, textP, 2);    //
>      setFieldTextFromString (ResultsClCrField, textP);
>  }
> These two functions within FillInRestults() reside in Utilities.c.
> The de{*filter*} shows crcl = 96.4432... Just before dropping into the
> doubleToString() function. Once inside doubleToString(), crcl is for some
> reason showing up as 16473.

> I have used the exact same code for doubleToString() in several other
> projects (all consisting of 1 source code file) and it works just fine. What
> that heck is wrong here?

> Any help is greatly appreciated.

> Andy

What you can probably do is,

1. add a header file to proj eg: a.h

2. add to a.h, extern double crcl;

3. #include a.h  to your main() c file

4. in your main() c file, initialise double crcl = 0.0;

5. add a.h to all your .c files.

this worked for me.



Tue, 08 Feb 2005 22:18:37 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. This is driving me nuts [C]

2. Linked List driving me nuts...

3. Weird asynchronous COM Calls driving me NUTS!

4. msdn docs drive me nuts, help find CDaoTableDef connect string format description

5. LNK2001 is driving me nuts!

6. Basic While Loop question driving me nuts!!!

7. This is driving me nuts!!

8. ToolBar, it drive me nuts

9. msdn docs drive me nuts, help find CDaoTableDef connect string format description

10. PInvoke is driving me nuts!!!

11. PLEASE Help (Going nuts here) - Variable problem

12. global variables and external variables?

 

 
Powered by phpBB® Forum Software