How to use preprocess​or directives (#define) in C++ header file with LabVIEW 8.2

I have a C++ header file that contains around 2000 preprocessor directives:
#define MEM_1   0xC
#define MEM_2   0xD
#define MEM_3   0x18
I want to be able to "access" these memory offsets by identifier name (MEM_1) in my LabVIEW program like I would in a C++ program.  I do not want the overhead of parsing through the header file and storing all the offsets into an array or similar structure. 
I've written a simple Win32 console program to return the memory offset given the identifier (see code below), and created a DLL to use with my LabVIEW program.  In the console program, you notice that I can call a function and pass in the identifer name, and get the offset back correctly:
getOffset(MEM_1);
In LabVIEW, I was hoping to be able to pass in the identifier (MEM_1) but was unsure what datatype to use.  In my C++ code, I defined the parameter as an int.  But in LabVIEW, I can't enter in MEM_1 as an int.   Can someone advise on how to do this?  Or if there is an alternate way to use #define's from external code inside LabVIEW?
#include "stdafx.h"
#include "scrmem.h"
#include "stdio.h"
void getOffset (int var);
int _tmain(int argc, _TCHAR* argv[])
 getOffset(MEM_1);
canf("%d");
 return 0;
void getOffset (int var)
 printf("The address of MEM_1 is %x", var); 

kaycea114 wrote:
Hi,
Where do you think I should use the string? 
The way that getOffset is currently defined in the DLL, I have to connect an integer input into the LabVIEW function.  This prevents me from entering in: MEM_1 as the input to the LabVIEW function.
Are you suggesting that I change getOffset to receive a String parameter ("MEM_1")?  Does that mean I need to do a string compare (line by line) through the header file to get the offset?  It seems like doing this search through the header file would degrade performance, but if that's the only work around, then I'll do it.
Please advise.
Well, what you want to do is indeed entering a string and getting back the assigned integer. That is what the C preprocessor is doing too although there it is done only once at the preprocessor stage of course and not at runtime anymore. But LabVIEW is not a C preprocessor.
What you did so far seems to be to define getOffset() that accepts an enum that needs to be created from the C source code to then return the assigned constant. That's of course not very helpful.
And writing a VI that could parse the C header file and create a name/constant array is really a lot easier than doing the same in C. You don't even need to parse the file each time again, but can instead cache them in an uninitialized shift register (LV2 style global).
Even more easy would be to create from that data a ring control using property nodes and save it as custom control and voila you have the most direct lookup you can get in LabVIEW and it works just as comfortable as using the define in C code. It would mean that you need to seperate your header file possibly into several different files to only get related constants into the same ring control, but that is easily done.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • How to use labjack U12 to control solenoid directiona​l valve with Labview in hydraulic system

    Hi,
    I need to control a solenoid operated direactional valve in hydraulic system with Labjack U12. I am using three relays but need some help on the vi. like which instrument drive I need to use etc....
    The coil voltage for the solenoid valve is :  AC120V, 60Hz; AC110V, 50Hz 
    My goal is to control this solenoid valve open/close at certin time, am using Labview 2011. Any advise would be helpful.
    Thank you!

    Have you got the relays working yet.  Do some initial testing with LJlogger to make sure hardware is controlling the relays as expected.  If you need further help with this step, provide a link to electrical details for the relays and describe how you have the relays connected to the U12.
    As for your programming in LabVIEW, I suspect you are using digital I/O, so the simplest thing to do is call EDigitalOut() to set a particular line to output-high or output-low, or if you need to set a line to input (for open-collector style control) use a call to EDigitalIn().  Perhaps look at "e function example.vi" to get started, and for general information about using the LabJack U12 with LabVIEW see topic #84 from the LabJack forums.

  • How to use RFBIBL00 as direct input in LSMW

    Can any one Please help how to use RFBIBL00 as direct input in LSMW ? How should be structure Same level or subordinate level as I will be having single text file ?
    I have around 15 fields with me
    BKPF
    STYPE     C     1
    BLDAT     C     10
    BLART     C     2
    BUKRS     C     4
    BUDAT     C     10
    XBLNR     C     10
    WAERS     C     3
    XPRFG     C     1
    XMWST     C     1
    BSEG
    STYPE     C     1
    NEWBS     C     2
    DMBTR     C     10
    KOSTL     C     10
    SGTXT     C     10
    PRCTR     C     10
    NEWKO     C     10
    MWSKZ     C     2
    Thanks and Regards
    Guru

    Hi,
    look testabap RFBIBLT0, which creates testfile
    A.

  • Can anyone give me simple instructions on how to use more than one ipod on the same computer with itunes? Both my daughters have ipods, my wife has one

    Dear All
    Can anyone give me simple instructions on how to use more than one ipod on the same computer with itunes. My daughters have a different generation 'nano' each & my wife a 'shuffle'?
    Many thanks

    Click here for options.
    (69081)

  • How to use airport time capsule on a dell portable pc with windows 7 taking in consideration that Time machine doesn't run with Windows ?

    how to use airport time capsule on a dell portable pc with windows 7 taking in consideration that time machine doesn't run with Windows ?

    TM does not work like that.
    If you want files to use later.. do not use TM.
    Or do not use TM to the same location. Plug a USB drive into the computer and use that as the target for the permanent backup.
    Read some details of how TM works so you understand what it will do.
    http://pondini.org/TM/Works.html
    Use a clone or different software for a permanent backup.
    http://pondini.org/TM/Clones.html
    How to use TC
    http://pondini.org/TM/Time_Capsule.html
    This is helpful.. particularly Q3.
    Why you don't want to use TM.
    Q20 here. http://pondini.org/TM/FAQ.html

  • We have a corporate iPad in our auto showroom to show guests how to use features on their vehicles. Someone locked it with their account. It was not an employee. How can I get in? I did a restore of the software already?

    We have a corporate iPad in our auto showroom to show guests how to use features on their vehicles. Someone locked it with their account. It was not an employee. How can I get in? I did a restore of the software already?

    Gather up the proof that the dealership is the original purchaser of the iPad,
    and take the iPad & that proof to a physical Apple store for possible assistance.
    It is highly suggested that you make a genius bar appointment to avoid delay
    at the store:
    Make a Genius Bar Reservation
    http://www.apple.com/retail/geniusbar/
    If no Apple store close by, get the information mentioned above and contact
    Apple Contact Us for assistance.
    Once the problem is resolved, you may wish it use Guided Access to limit
    what customers can do with the iPad.
         iOS: About Guided Access - Apple Support

  • How come you can not use more than 126GB of a 1.5TB diskdrive with LabVIEW Real Time?

    How come you can not use more than 126GB of a 1.5TB diskdrive with LabVIEW Real Time?
    This is only 8.3% of the available disk drive space!
    http://digital.ni.com/public.nsf/allkb/E7E2F5657B6​026358625750B007201A6?OpenDocument
    National Instrument's solution is either reformat you drive to less than 126GB or replace the drive with one less than that size.
    Please NI, tell me you are going to fix your LabVIEW Real Time soon, and that we won't have to wait for LabVIEW RT 9.2.1 in 2011 for this one to be fixed.
    http://upload.wikimedia.org/wikipedia/commons/9/90​/Hard_drive_capacity_over_time.svg
    Drives as large as 126GB or more have been around since about mid 2002.  That's about 7 Years now and LabVIEW Real Time STILL can't use drives larger that 126GB!  Please NI.  Do something.
    We deserve fixes to the old versions of LabVIEW RT.  How about updates to LabVIEW RT.  Such as 7.0.2, 7.1.2, 7.6.2, 8.0.2, 8.2.2, 8.6.2.
    We don't need new features or versions of LabVIEW RT such as 9.0 until we have some of bugs fixed in the existing versions. 
    Kevin. 
    Message Edited by kmcdevitt on 05-29-2009 03:39 PM
    Solved!
    Go to Solution.

    Coq rouge wrote:
    NI is not making the Real Time OS in house. I do not remember which firm that is making it. Anyway you are allowed to use a hard drive that has been partitioned. And 126GB is some space is it not? I remember Bill Gates declared one time that 640Kb ram should be more than enough for any PC application also in the future 
    Coq Rouge (formerly t06afre),
    The RealTime OS is an NI Product that is purchased from NI.
    NI may or may not outsource design, developement, or manufacturing of the products that it sells under its own Company name.
    For this reason I would be concerned if I were a PXI Embedded Controller designer/developer in the United States. 
    Yes, 126GB is some space.  I see that there are now 2TB drives available.  126GB would be 6.3% of a new 2TB drive.  Should we all be happy with being able to use 6.3% of the available drive space.  Moore's Law seams to be alive and well.  Drives larger than 126GB have been readily available for 5 or 6 Years.  This should not be a surprise to NI.  Why don't they do something about it.
    Thanks for the trivia on Bill Gates.  I must have missed that one since I don't try to keep up with Microsoft.  I believe that he is a wonderful person and he and his family are doing wonders for the world in their "retirement".   The world needs more like him.
    What I do remember is Steve Jobs telling us that we would never need more that 128MB and that we would never to need to do anymore software development because everything was already in the "ToolBox".
    McKevin.  

  • HOW DO use the Mikey 2.0 iPod and iPhone Microphone with my IPHONE4

    HOW DO use the Mikey 2.0 iPod and iPhone Microphone with my IPHONE4

    Did the microphone come with a user manual? You might contact support for the microphone.
    Just so you know the iPhone 4 has a built-in microphone

  • I'm looking into how apps use the cloud. Would you consider any app with social media access as uploading information to the cloud? e.g. being able to tweet through an app is the same as uploading data to the cloud

    I'm looking into how apps use the cloud. Would you consider any app with social media access as uploading information to the cloud? e.g. being able to tweet through an app is the same as uploading data to the cloud

    Most of us in this forum are users who volunteer on technical issues, and not Adobe employees although they do drop in from time to time. As users we simply have no control over activation and that's why you are not getting responses.
    If you havn't done so,you might try the Muse forums and see if you can get a staff member to look into it. Have your case numbers and phone transcripts handy.
    Last option is to keep calling customer service until you get someone who will help or ask for a supervisor.
    Hope this get resolved,
    Gene

  • How to include header files with different extensions

    Hi,
    When i include a header file with extension .ch (myincludefile.ch), the compiler gives error messages but when i change the extension to .h, the problem disappears.
    Can anyone help me getting rid of this problem?
    For example, for the line below, I get a warning such as, "attempt to redefine MY_CONST without #undef". Remember when i change the extension to .h, the problem disappears.
    #define MY_CONST 500 /* Constant */
    Thank you very much

    I don't see how the name of the file could cause or prevent error messages, except when template declarations are involved. So let's assume for now that the file has a template declaration.
    The Templates chapter of the C++ Users Guide explains about including or separating template declarations and their definitions.
    If you have only a template declaration in a file and the compiler needs the definition, it will look for another file with the same base name and include it automatically. For example, if you have files foo.h and foo.cc, and foo.h has a template declaration, the compiler will include foo.cc automatically, even if you didn't intend for that to happen. You can wind up with multiple delcaration errors that way.
    When looking for a file containing template definitions, the compile will not include a .h file, so as not to create recursive inclusion. If changing the file name to .h causes your problem to disappear, it seems like an unwanted automatic inclusion is the problem.
    You can try two things to find out:
    1. Compile with the -H option. The compiler will output an indented list of all included files. See if you are getting a file you didn't intend, or the same file twice.
    2. Compile with option -template=no%extdef. It disables the automatic search for template definitions.
    If you find an unintended included file this way, you will probably have to change the names or organizaiton of some of the files. Our implementation of the C++ standard library depends on NOT using the -template=no%extdef option, which might mean you can't use that option.

  • How to get string (specified by line and column) from txt file with labview

    Hi everyone
    How to get string (specified by line and column) from txt file with labview
    thx 
    Solved!
    Go to Solution.

    As far as I know, a text file has no columns.  Please be more specific.  Do you mean something like the 5th word on line 4, where words are separated by a space, and lines are separated by a newline character?  You could the Read from Spreadsheet String function and set the delimiter to a space.  This will produce a 2D array of strings.  Then use index array and give the line number and column number.
    - tbob
    Inventor of the WORM Global

  • How to read the date and time information of a file by labview

    how to read the date and time information of a file by labview? for example, created time and modified time.
    Solved!
    Go to Solution.

    if you need to know the last modification date of file:-
    "Functions->File I/O->Advanced File Functions->File/Directory Info.vi"
    This vi returns the value of file's last modification date. This is returned as U32 number. To see it in MM/DD/YY format you must create the indicator, right-click on it and select "Format & Precision" item from drop-down menu. Then select "Time and Date" format there.
    Thanks as kudos only

  • Using Cpp code and header files with LV8 CIN

    Hello,
    I have three pieces of C++ code and their header files that are called from a Main C++ code.  I want to call these from a LV8, code interface node (CIN).  I have the C++ compiler installed on teh same machine as LV8.  My questions are:
    1) How do I call the C++ code anf the header files from the LV CIN?  I have never doen this. Is there a concise manul for this somewhere?  Teh last thing any self-respecting engineer wants to do is read the manual.
    2)  Once I successfully call teh C++ and header files from within the CIN, can I create a LV runtime executable, just as I can with any other LV8 .vi?  Will this runtime .exe run stand-alone as a distribuatble application?  Do I need to include any special runtime files when I build the exectuable to support teh C++ code?
    Thank you.

    http://forums.ni.com/ni/board/message?board.id=231&message.id=2424&requireLogin=False
    handles your question.

  • HT4597 I use the public folder on idisk to share files with a colleague. Will I be able to do the same on iCloud?

    I use the public folder on idisk to share files with a colleague. Will I be able to do the same on iCloud?

    No. There is no iDisk with iCloud. You can use one of several third-party alternatives like SugarSync, ADrive, or MediaFire.
    Basic Information About Moving From MobileMe to iCloud
    Apple IDs and iCloud
    Creating an iCloud account- Frequently Asked Questions
    Frequently asked questions about the MobileMe transition and iCloud
    MobileMe services that no longer sync after moving to iCloud
    MobileMe- About moving to iCloud

  • Is anybody use Hyper File with LabView?

    Is anybody use Hyper File with LabView?
    I Have a project that need to conect to a hyper file data base Made by PCsoft.
    Thanks
    Benoit Séguin
    Software Designer

    I have never used HyperFile, but a quick check of the company's website indicated that there are ODBC drivers available for it so it should be a simple matter connecting through ADO.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

Maybe you are looking for

  • How do I remove my deceased mother's Apple ID from her iPad?

    I received my mother's iPad2 when she passed away in June. It works better than my original iPad2 since I broke part of the glass on mine. I have added my apple ID to her iPad, changed to my ID at the bottom of the screen at the App Store but it stil

  • Help!  My folder in iphoto has disappeared

    Hello I have 12 folders in iphoto, which each have many albums.  I try to keep just 12 events as well which match the names of my folders. My folder called 'work' has disappeared.  It doesn't seem to be in any of the other folders.  However the event

  • XI30 File Adapter - check for (NOT) incoming file

    Hi! We use XI30 SPS15 and have the following challenge: We expect every week on a certain day a file coming from a customer. So far so good. But now we want to check whether such a file has really come within a given period of time and if not, we wan

  • BEx Prompt not visible in webi

    Hello EveryOne, I am creating a Web intelligence Report on BEx query ( Coming from .UNV Universe ) , My problem is i have used two key dates in query . One is visible in webi another one is not. In Query analyzer both dates are visible . Can someone

  • Javascript mouse over

    i'm trying to do a mouse over effect on my buttons where they swap images everytime a mouse hovers over the button. I've tried to enter the javascript line suggested by http://swforum.sun.com/jive/thread.jspa?threadID=53771 ,here is what i put: docum