LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

communicate between two C files

Hi ,
I am using LW/CVI in my project . Now I need to break the lenthy code into some parts .That is I want to have more than one .c files so that during debugging problems can be minimized .Now tell me how can I communicate among these .c files in a single application code ?
 
With Regards
subrata
0 Kudos
Message 1 of 4
(4,115 Views)

Hello Subrata,

What do you mean by "communicate among these .c files" ?

Share variables, call functions that are defined in an other .c file ? Just let me know.

Regards,

0 Kudos
Message 2 of 4
(4,112 Views)
Dear Mathieu STEINER ,
 
I mean to say I have three .c files named, A.c,B.c,C.c .Amongst these three A.c has main( ) function from where execution starts .Now at some condition I need to transfer control from A.c to B.c and there(B.c) it may or may not happen that I need to use a user-defined function that is defined in A.c or C.c .Then I need to come back to A.c or go to C.c . For this kind of transfer of control and usage of functions / variables what I should do ,Plz reply me soon .
 
subrata
0 Kudos
Message 3 of 4
(4,107 Views)
subrata, a simple application could be handled as follows:
  • Split your source code into the desired files. DO NOT include function and variable definitions in the source files
  • Create a global include file with all function definitions. #include this file into all your source files
  • Place global variable definitions into the global include file: these will be available to all functions in the program, whichever is the source code functions are in
  • The same with macros and other useful elements you need

A similar but more structured approach can be found taking as an example iconedit application shipped with CVI ( <cvidir>/samples/apps/iconedit folder 😞 here every source file has an associated header file with functions and variable definitions for elements common to more than one module; these files are included in every source file that needs them; elements confined to a single source file are defined at this level.

Such an approach in my opinion, while it is correct for large, modular and heavily structured applications, is oversized for little ones and can be difficult to understand and maintain (i.e. the cost of this structure is not justified by the application type). But this evaluation is heavily dependent on personal and company standards.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 4
(4,093 Views)