delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/09/06/22:55:40

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Message-Id: <3.0.1.16.20030906222542.1b57b6ee@earthlink.net>
X-Sender: ethros AT earthlink DOT net
X-Mailer: Windows Eudora Light Version 3.0.1 (16)
Date: Sat, 06 Sep 2003 22:25:42 -0400
To: djgpp AT delorie DOT com
From: Ethan Rosenberg <ethros AT earthlink DOT net>
Subject: far pointers
Mime-Version: 1.0

Dear mail list -

I sent this origianaly on 4 Sept.  Due to the outage of the server, it sems
never to have ben posted.  Thanks in advance for every thiing.

Ethan



Dear mail list -

I am trying to compile the code below, which uses far pointers, and was
written for Microsoft C.  The compilation dies in the header file
[attached].  I'm really not conversant in this area, and would greatly
appreciate some help.

MUCH THANKS IN ADVANCE.

Ethan Rosenberg
***************
HEADER FILE [part of it]


/*
 * Copyright (C) National Instruments 1994.
 * Function prototype file for C programs using
 * NI-DAQ DOS 4.6
 * nidaq.h
 */

#if (__STDC__ == 1) && (_MSC_VER != 600)
  #if (__TURBOC__ >= 1040) || (_MSC_VER >= 700)
    #define ND_CDECL extern int far __cdecl
  #else
    #define ND_CDECL extern int far
  #endif
#elif (_MSC_VER != 500)
  #define ND_CDECL extern int far _cdecl
#else
  #define ND_CDECL extern int far
#endif

#ifdef __cplusplus
  extern "C" {
#endif
/*  >>>>> the compilation dies at this point<<<<<<<<<<*/
ND_CDECL A2000_Calibrate (int device, int saveNewValues, int calMethod,
         int channel, double extRefVoltage);
ND_CDECL A2000_Config (int device, int sampClkSrc, int sampClkDrv,
         int dither);
ND_CDECL A2150_Calibrate (int device, int ref0, int ref1);
ND_CDECL AI_Check (int device, int far *status, int far *value);

<snip>

PROGRAM [part of it]

/****************************************************************************
   To make an executable file for this program:
   1. Compile this file and its support files by the commands:
      cl /c /AL scanxmpl.c
      cl /c /AL getdev.c
      cl /c /AL errprint.c
      cl /c /AL plot.c
   2. Link the three object files produced, the NI-DAQ DOS library, and the
      Microsoft graphics library by the command:
      link /SEG:175 scanxmpl getdev errprint plot ,,, nidaqmsc graphics;

   A makefile in this directory named scanxmpl.mak will perform all of the
   above operations for you.  To use the makefile, please refer to the
   instructions in the makefile.

Note to Borland Compiler users:
   The plot.c file was written using Microsoft C graphics. It is not
   compatible with Borland compilers.  You should either create another
   plot source file using Borland graphics, or you can take the plot
   function calls out of this program.

   The compile and link commands listed above are for the Microsoft C compiler
   and linker. You must alter these to work with the Borland compiler and
linker
   that you are using. The make file for this example will also have to be
   changed in order to be compatible with Borland make utility that you are
   using. Additionally, nidaqmsc.lib must be replaced by the library
   nidaqbc.lib.
****************************************************************************/

#include <stdio.h>
#include <libc\farptrgs.h>  /* I ADDED THIS CODE, HOPING IT WOULD HELP. IT
DIDN'T */
#include "nidaq.h"       /* function definitions */
#include "nidaqerr.h"    /* error code definitions */
#include "nidaqcns.h"    /* NI-DAQ constants definitions */

#define  MAXCHNS      16      /* the maximum number of channels */
#define  PTSPERCHAN 1000      /* the number of data points to acquire per
                                 channel */
#define  NUMPOINTS (MAXCHNS * PTSPERCHAN) /* total number of points to
acquire */

int huge plotBuf[PTSPERCHAN]; /* buffer for storing acquired data */

/****************************************************************************
   This is an example of a Microsoft C application that calls NI-DAQ DOS
   functions for programming multiple A/D conversions.
   The input channels are selected by the user.
****************************************************************************/

main()
{
   void   ErrClean();            /* error message and clean up procedure */
   extern int getDeviceToUse();  /* procedure for getting the device number */

   int   i,              /* loop counter and array index */
         deviceNumber,   /* device number of device */
         err,            /* holds NI-DAQ DOS error code */
         useISCANcall,   /* is non-zero if device is a Lab board, LPM-16,
                            SCXI-1200, DAQPad-1200 or DAQCard-700 */
         num_chans,      /* number of channels to be scanned */
         chans[MAXCHNS], /* array storing channels */
         gains[MAXCHNS], /* array storing gains */
         finalScanOrder[MAXCHNS],   /* for Lab_ISCAN_Op call */
         plot_chan,      /* channel number to plot */
         memHandle;      /* handle to NI_DAQ_Mem_Alloc'd memory */

   unsigned long
         num_pts,        /* actual number of points   */              
         deviceCode;     /* device code indicating the type of device */

   unsigned int
         no_bits;       /* Number of A to D bits in the corresponding
device */

   long  timeoutTicks,  /* for the Timeout_Config call */
         lockHandle;    /* lock handle to NI_DAQ_Mem_Alloc'd memory */

   double rate,         /* the acquisition rate in points per second */
          scanRate;     /* rate in scans per second */

   char   cr;           /* used to consume carriage return in scanf */

/*---------------------------------------------------------------------*/
   printf("\nThis example will operate on an MIO board, Lab board,
SCXI-1200, ");
   printf("\nDAQPad-1200, LPM-16 or DAQCard-700");

   /* Link relevant parts of the library for MIO E Series boards.    */
   /* You can delete the following function call if you do not       */
   /* want to use this program with any MIO E Series boards.         */
   err = USE_E_Series_DAQ();
   ErrPrint("USE_E_Series_DAQ", err);

   deviceNumber = getDeviceToUse ();

MAKEFILE

# To use this makefile with Microsoft C compilers, use the following command:
#    nmake /f scanxmpl.mak  (Version 6.0 and above)
#    make scanxmpl.mak      (Version 5.1)

# The /c flag directs cl to compile only and not produce an excutable file
# The /AL flag directs cl to use the large memory model when compiling
FLAGS=/c /AL

# The /SEG flag specifies number of segments that the linker allows your
# program to have.
LINKER_FLAGS=/SEG:175

all: scanxmpl.exe

errprint.obj : errprint.c
	cl $(FLAGS) errprint.c

plot.obj : plot.c
	cl $(FLAGS) plot.c

getdev.obj : getdev.c
	cl $(FLAGS) getdev.c

scanxmpl.obj : scanxmpl.c
	cl $(FLAGS) scanxmpl.c

scanxmpl.exe : scanxmpl.obj getdev.obj errprint.obj plot.obj
	link $(LINKER_FLAGS) scanxmpl getdev errprint plot ,,, ..\lib\nidaqmsc.lib
graphics;


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019