06-20-2007 06:54 AM
Hy,
I’ve got two c-files. One with the main-function and the other with a subroutine.
When the user set the #define to 1 the program should work with the subroutine.
But it doesn’t.
I already read other posts concerning this subject but it didn’t help me.
Thanks for helping me.
The program doesn’t print: "The function ‘temperatur’ has been executed"
Here my program.
------------------------------
/* temp.h */
#include <ansi_c.h>
--------------------------------
/* main.h */
#include <ansi_c.h>
#include <utility.h>
#define TEMP 1 // the user set 1 or 0
--------------------------------
/* temp.c */
#include "temp.h"
void temperature()
{
printf("The
function ‘temperatur’ has been executed");
}
/* main.c */
#include "main.h"
#include "temp.h"
void main()
{
if(TEMP)
{
void
temperature();
printf(“TEMP=1”);
}
else
{
printf(“TEMP=0”);
}
}
06-20-2007 07:53 AM
Hy,
i'm not sure how c ansi reacts to if(1) or if (0), so how about
if(TEMP == 1)
{
void temperature();
printf(“TEMP=1”);
}
else
{
printf(“TEMP=0”);
}
?
Greetings
Norbert
06-20-2007 08:10 AM
void main()
{
if(TEMP)
{
void temperature();
printf(“TEMP=1”);
}
else
{
printf(“TEMP=0”);
}
}
JR
06-20-2007 08:56 AM
06-20-2007 09:50 AM
In both your temp.h and temp.c files, instead of void temperature() you could try void temperature(void) instead. I assume all these files are within your CVI project?
BTW, you should never #include a .c source file inside another one. Leads to all sorts of problems.
JR
06-21-2007 05:39 AM
#include "temp.h"
void temperature ()
{
printf("The function 'temperature' has been executed");
}
-----------------------
/* main.c */
#include "main.h"
void main()
{
if(TEMP)
{
temperature();
printf("TEMP=1\n");
}
else
{
printf("TEMP=0\n");
}
Delay(10.0);
}