09-10-2009 01:10 PM
is there way to call multiple main in a project.
Now dont get me confuse. I do know how to go the header file route. I was just wondering if there is a new way of calling multiple mains.
basically i already have project open. but i want to include another project in the same workspace that has a main also.
but in the second project i want to call the function call in the first project.
is there a way to do it. i have already include the 2nd project in the workspace, but when i call it in the first project it saids undefined symbol
reference in my c file.
09-10-2009 01:31 PM - edited 09-10-2009 01:38 PM
Darnell:
Function names need to be unique in any project, so you cannot call multiple main's.
The best way to call functions in one project from another is to have the project with the calling functions set to generate an executable, and the project with the called functions set to generate a DLL. Search the CVI help for DLL. There are a few good articles there on generating and debugging DLLs.
Another option is to have the functions you want to call in a separate .c file, not the .c with your main(), and include the called-function .c file in both projects.
Having multiple projects in a workspace does not give you access to the functions in both: it's just a convenient way in the CVI environment to switch between projects. You need to include a .c, and/or .h, and possibly .lib files in a project where you want to call the functions.
09-10-2009 01:46 PM
09-10-2009 02:03 PM
In any case, you need more than a .h file. If you are building an EXE and a DLL, your calling project (EXE) needs to include the DLL's .lib and export .h files. If you are only building an EXE, you need to include the .c file(s) and the .h file(s) of the functions you want to call. Remember that you need to have the called functions in a .c file separate from the main() in your second project.
If you're interested in DLLs, I'd suggest that you look at the sample DLL projects that ship with CVI and at the example I posted to one of your earlier questions here: http://forums.ni.com/ni/board/message?board.id=180&message.id=42707&query.id=1161309#M42707
09-10-2009 05:07 PM
ok i got another question. im done with header file situation.
my problem is trying to call it and then it gives me an error do you know why
body { margin: 0 0 0 0; padding:0 0 0 0 } td,div { font-family:Tahoma;font-size:12pt;vertical-align:top } body { margin: 0 0 0 0; padding:0 0 0 0 } .transcript { background-color:#d2d2d2; } .messageBlock { margin-left:4px; margin-bottom:3px } .message { margin-left:100px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre; } .messageCont { margin-left:100px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre;} .other { color:#39577a;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .myself { color:#da8103;font-style:normal;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont { font-size:8px;text-align:right; color:#39577a;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .myselfCont { font-size:8px;text-align:right; color:#da8103;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .system { margin-left:4px; word-wrap:break-word;color:#da8103;font-style:normal;font-weight:normal; white-space:-moz-pre-wrap; _white-space:pre; } .showTimestamp { margin-right:3px; float:right; color:#999999;font-style:normal;font-weight:normal; } .other1 { color:#ac2000;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont1 { font-size:8px;text-align:right; color:#ac2000;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other2 { color:#3c9fa8;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont2 { font-size:8px;text-align:right; color:#3c9fa8;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other3 { color:#e25614;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont3 { font-size:8px;text-align:right; color:#e25614;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other4 { color:#0b6ac8;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont4 { font-size:8px;text-align:right; color:#0b6ac8;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other5 { color:#b23290;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont5 { font-size:8px;text-align:right; color:#b23290;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other6 { color:#02e7c7;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont6 { font-size:8px;text-align:right; color:#02e7c7;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other7 { color:#5b3284;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont7 { font-size:8px;text-align:right; color:#5b3284;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .tsDisplay { display:block }
09-10-2009 05:10 PM
ok i got another question. im done with header file situation.
my problem is trying to call it and then it gives me an error do you know why pertainingto the last post i sent
09-10-2009 05:53 PM
Darnell:
Thanks for including the error message in your post. That's helpful to us, but it should be helpful to you as well.
In your prototype for your function, you said that the first parameter is a multi-dimensional array of pointers. When you called the function, you didn't pass the pointer to an array: you passed the pointer to one element.
So you got the error because the compiler couldn't convert the datatype you were trying to pass to the datatype you told the compiler to expect.
cannot convert parameter 1 from 'double *' to 'double *[][1000]'
Go to your C reference book or textbook, and read the section on passing array to functions.
Do you understand why you are declaring an array of pointers instead of an array of doubles?
09-10-2009 06:22 PM
i tried everything,
(f_ConvDblToSingleArray( &temp_data,
&meas[3000] ,
q ));
i tried it this way also
and i also tried it the book way also
09-10-2009 07:09 PM
Darnell:
I've responded before to your comments that you have "tried everything". When it comes to posts on this forum, I'd suggest that you just take those words out of your vocabulary. They just get in the way of you getting help here.
Let's look at this statement:
f_ConvDblToSingleArray( &temp_data, &meas[3000] , q )
In your calling routine, you declared temp_data as a multi-dimensional array of doubles.
In your function prototype, you declared double_array as a multi-dimensional array of pointers to doubles.
&temp_data is a pointer to the array of doubles, not an array of pointers to doubles.
In your calling routine, you declared meas as an array of doubles.
In your function prototype, you declared single_array as an array of pointers to doubles.
&meas[3000] is a pointer to a double (one single element of the array), not an array of pointers to doubles.
What is the "book way"? What book are you using? Please post the title and author of your book and the reference of how to pass arrays.
On to other comments. What are you trying to do with the following statements?
double temp_data[4][3000] = { 0.0 };
double meas[3000] = { 0.0 };
Do you realize that you are only setting the first element of each array and not the entire array?
Here's what I consider the bigger picture. I was giving you a hint when I asked why your function was using arrays of pointers. Sometimes you need the flexibility you get by using arrays of pointers, but for your simple function, I would suggest using arrays of doubles, not arrays of pointers.
So here's your new function prototype:
long f_ConvDblToSingleArray ( double double_array[4][1000], double single_array[3000] , int max_index );
Here's your call to that function:
f_ConvDblToSingleArray( temp_data, meas, q );
To simplify these statements for the purposes of demonstration, I removed your "extern" declaration and the CHK() function.
Arrays and pointers are some of the fundamental concepts not only of C, but also of C++ (which you have told us is the language you are more familiar with).
In any strictly typed language, the parameter type you pass must be the same type the function expects. C and C++ can do some automatic casting (conversion of datatypes), but converting from pointers to doubles isn't something that you should expect any compiler to do.
You need to get a good understanding of these concepts or you will continue to get lost.
09-10-2009 07:13 PM