[Error] expected primary-expression before 'long'?

[no longer relevant]

Hello!

There is code:

#include "Windows.h"
#include <stdio.h>

#define DIM(a) (sizeof(a) / sizeof(a[0]))

#include "Include/DLLClient.h"
#include "Include/IADCDevice.h"

#include "Alf.cpp"
/*######################################################################*/
int Write(HANDLE hFile, void* p, unsigned size)
{
 if(hFile == INVALID_HANDLE_VALUE) 
 return 0;

 DWORD dw = 0;
 WriteFile(hFile, p, size, &dw, 0);
 return dw != size ? -1 : 1;
}
/*----------------------------------------------------------------------*/
int ReadALFFile(char* name, char* oname)
{
 // ìàññèâ äëÿ âðåìåííîãî áóôåðà
 fVolts float[8 * 1024];
 // íà óêàçàòåëü èíòåðôåéñ "IALF"
 IALF* pALF;
 DllClient DClient;

 // ïîëó÷åíèå ôèçè÷åñêîãî èíòåðôåéñà.
 pALF = (IALF*)DClient.LoadDriver("EL200E", "IALF");
 if(pALF == 0)
{
 printf("\n ERROR - EL200E driver not found! \n");
 return 0;
}

 // îòêðûâàåì ôàéë ñ SD äàííûìè
 if(pALF->Open(name) <= 0)
{
 printf("\n ERROR - Invalid ALF File! {%s}! \n", name);
 return 0;
}

 unsigned nBlockSize = 0;
 int nChan = 1;
 double dFreq = 1000.0;
 __int64 lFSize = 0L;
 unsigned nSSize = 0;
 int nCycle = 0;
 FILETIME ft;
 SYSTEMTIME st;

 // ïå÷àòü èíôîðìàöèè î ôàéëå 
 pALF->Get(IALF_BLOCKSIZE, &nBlockSize);
 pALF->Get(IALF_CHANNELLS, &nChan);
 pALF->Get(IALF_FREQ_DOUBLE, &dFreq);
 pALF->Get(IALF_SIZE_IN_SAMPLES, &lFSize);
 pALF->Get(IALF_SIZE_IN_SECTORS, &nSSize);
 pALF->Get(IALF_CYCLEMODE, &nCycle); 
 pALF->Get(IALF_FILETIME, &ft);
 pALF->Get(IALF_SYSTEMTIME, &st);

 printf("\n ----------------------------------");
 printf("\n File : %s", name);
 printf("\n Cnannels : %d", nChan);
 printf("\n Freq per Channell : %.2f", dFreq);
 printf("\n Size in samples : %LdKs", lFSize / 1024L);
 printf("\n Record Time : %.2f min.", lFSize / (dFreq * nChan * 60.0));
 printf("\n Size in sectors : %u", nSSize);
 printf("\n Start date : %02d-%02d-%d", st.wDay, st.wMonth, st.wYear);
 printf("\n Start time : %02d:%02d:%02d", st.wHour, st.wMinute, st.wSecond);
 printf("\n Cycle mode : %s", nCycle ? "YES" : "NO");
 printf("\n ----------------------------------\n");

 // â çàâèñèìîñòè îò òîãî êàêîé ôàéë ñîçäàâàëñÿ, öèêëè÷åñêèé èëè íåò,
 // íóæíî ïîçèöèþ íàéòè íà÷àëà çàïèñè. Íóæíî ïðîñòî Ýòî ìåñòî â ïåðåíåñòè
 // ñâîé êîä.
 pALF->Reset(0, 1);

 __int64 sm = 0x7FFFFFFFFFFFFFFFL;
 unsigned sindex = 0;
if(nCycle)
{
 for(unsigned j = 0; j < nSSize; ++j)
{
 __int64 in[2];
 if(pALF->GetIndex(1, in) <= 0)
break;

 if(in[0] == in[1])
break;

 if(sm > in[0])
{
 sm = in[0];
 sindex = j;
}
 if(sm > in[1])
{
 sm = in[1];
 sindex = j;
}

 if((j & 0x7F) == 0)
 printf("\r Scan = %u sec. ", j);
}
 printf("\n First sector Found! Sector = %u, %Ld \n", sindex, sm);

 ULARGE_INTEGER ut;
 ut.LowPart = ft.dwLowDateTime; 
 ut.HighPart = ft.dwHighDateTime;
-->> ut.QuadPart += __int64(sm * nBlockSize / (dFreq * nChan) * 1e7);
 ft.dwLowDateTime = ut.LowPart; 
 ft.dwHighDateTime = ut.HighPart;
}

pALF->Reset(sindex);

 // çàãîëîâîê çàïèñûâàåòñÿ âûõîäíîãî ôàéëà, 
 // Âû ìîæåòå çàïèñûâàòü äàííûå â ëþáîì ñâîåì ôîðìàòå.
 HANDLE hFile = SaveALFHeader(oname, nChan, dFreq, 0);

 for(unsigned i = 0; ; ++i)
{
 // ïîëó÷åíèå ïîðöèè äàíûõ. Âñå äàííûå ïîëó÷àþòñÿ â ôîðìàòå
 // float è ïðåäñòàâëÿþò ñîáîé íàïðÿæåíèå â Âîëüòàõ ïðèâåäåííîå êî âõîäó.
 unsigned n = pALF->GetVoltage(0, fVolts, DIM(fVolts));
 if(n == 0)
break;

 printf("\r Save = %u Ks. ", i * DIM(fVolts) / 1024);

 // Â ýòîì ìåñòå ìîæíî çàïèñûâàòü äàííûå â ëþáîì äðóãîì ôîðìàòå,
 // èëè íåïîñðåäñòâåííî èñïîëüçîààòü èõ.
 if(Write(hFile, fVolts, n * sizeof(float)) <= 0)
{
 printf("\n ERROR - Save File! \n");
break;
}

 if(n < DIM(fVolts))
break;
}

 CloseALF(hFile, ft);

pALF->Release();
 return 1;
}
/*----------------------------------------------------------------------*/
int main(int argc, char **argv)
{
 if(argc < 2)
{
 printf("\n Usage : Input[ALFSD FileName] Output[ALFVolt FileName].");
 return 0;
}

-->> if(ReadALFFile(argv[1], argc > 2 ? argv[2] : "Dat.ALF") > 0)
 printf("\n ALF file save OK!");
else
 printf("\n Invalid ALF File!");
 return 0;
}
/*######################################################################*/


When compiling there are two errors:

5d46d5d23b2ea752982210.jpeg

Problem areas in the code I marked with arrows -->>.
Runtime Dev C++ 5.11.

I do not understand what he wants. Please suggest.
March 25th 20 at 13:17
1 answer
March 25th 20 at 13:19
-->> ut.QuadPart += __int64(sm * nBlockSize / (dFreq * nChan) * 1e7);

Perhaps the reason that ut.QuadPart - this is an unsigned 64-bit integer, and __int64 is a landmark.

-->> if(ReadALFFile(argv[1], argc > 2 ? argv[2] : "Dat.ALF") > 0)

The oname parameter functions ReadALFFile is of type char*and type string constants "Dat.ALF" - const char*
Perhaps the reason that ut.QuadPart - this is an unsigned 64-bit integer, and __int64 is a landmark.

Rather, the reason is that the castes to __int64 is completely wrong:

(__int64)(sm * nBlockSize / (dFreq * nChan) * 1e7);

Actually, he probably does not need. - Tianna_Rodriguez27 commented on March 25th 20 at 13:22

Find more questions by tags C++