How to Convert C++ Driver Example to LabWindows/CVI

Knowledge Base Article # Q200306

Read Prior Article Read Next Article
Summary This Knowledge base will give guidance on how to convert Marvin Test Solutions C++ Driver Example to LabWindows/CVI.

Introduction

This Knowledge base will give guidance on how to convert Marvin Test Solutions C++ Driver Example to LabWindows/CVI. Since CVI is based on C and not C++ we need to convert some types from C++ to C.

Steps to Convert Examples

Step 1: Create LabWindows/CVI Project

Create the LabWindows/CVI project in the Examples\LabWindows\ folder. Save it at GxXXXExampleC.

Step 2: Copy Example files to the LabWindows folder

Copy GxXXX.h, GxXXX.lib and GxXXXExample.cpp files into the newly created folder. Rename the .CPP file to .C as LabWindows only works with C files.

Step 3: Insert the Example files into the LabWindows/CVI project.

Insert GxXXX.h, GxXXX.lib and GxXXXExample.c files into the newly created project.

Step 4: Modify the GxXXX.h file.

In the GxXXX.h file there is a piece of code that needs to be modified.

The original code looks like:

GxXXX.h prior to any change being made

After the change is made:

GxXXX.h after the change is made

Step 5: Modify the GxXXXExample.c code to account for C++ to C changes.

The following changes need to be made to the C file to account for the change in language from C++ to C.
  • false needs to changed to FALSE
  • true needs to be changed to TRUE
  • new needs to be changed with malloc

    Example:
    padwDataWr = new DWORD[dwDmaByteCount];
    becomes
    padwDataWr = (DWORD *) malloc(sizeof(DWORD) * dwDmaByteCount);
  • delete[] needs to be converted to free

    Example:
    delete [] padwWr;
    becomes
    free(padwDataWr);
  • atoi() needs to be converted to (BYTE)atoi()

    Example:
    atoi(szParameter);
    becomes
    (BYTE)atoi(szParameter)

Conclusion

To convert a C++ example to LabWindows/CVI can be done, but there are some challenges that need to be met. When converting your own C++ code to LabWindows, be aware of any language specific changes that need to be made.

Download LabWindows/CVI Example showing converting the C++ provided with GXFPGA driver converted to C.

Article Date 4/25/2017 5:54:19 PM     Updated: 4/26/2017 8:07:00 AM
Keywords C++ to C; LabWindows; CVI; LabWindows/CVI

0 ratings | 0 out of 5
Read Prior Article Read Next Article