Compiling a program on Windows C ++ in g ++

I am trying to compile a program on Windows C ++ in g ++. This is what I get.

/usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. btree.cpp:1204: error: '_TCHAR' has not been declared btree.cpp: In function 'int _tmain(int, int**)': btree.cpp:1218: error: '__int64' was not declared in this scope btree.cpp:1218: error: expected ';' before 'frequency' btree.cpp:1220: error: 'LARGE_INTEGER' was not declared in this scope btree.cpp:1220: error: expected primary-expression before ')' token btree.cpp:1220: error: 'frequency' was not declared in this scope btree.cpp:1220: error: 'QueryPerformanceFrequency' was not declared in this scope btree.cpp:1262: error: expected primary-expression before ')' token btree.cpp:1262: error: 'start' was not declared in this scope btree.cpp:1262: error: 'QueryPerformanceCounter' was not declared in this scope btree.cpp:1264: error: name lookup of 'i' changed for ISO 'for' scoping btree.cpp:1264: note: (if you use '-fpermissive' G++ will accept your code) btree.cpp:1304: error: expected primary-expression before ')' token btree.cpp:1304: error: 'end' was not declared in this scope btree.cpp:1306: error: 'total' was not declared in this scope btree.cpp:1316: error: 'getchar' was not declared in this scope 

The first thing I noticed was these type variables called _TCHAR, _int64 and LARGE_INTEGER, which is probably the thing of Windows. That they can be changed so that they work in g ++?

Also, if something else you know can be converted to g ++, that would be helpful.

I got the code from here: http://touc.org/btree.html

+4
source share
4 answers

On the linked page:

  // the main function is just some code to test the b-tree. it inserts 100,000 elements, // then searches for each of them, then deletes them in reverse order (also tested in // forward order) and searches for all 100,000 elements after each deletion to ensure that // all remaining elements remain accessible. 

If you don’t shoot at all, you should basically be good. __int64 and LARGE_INTEGER are used only so that QueryPerformanceCounter can be called and only called from the main function of the test. It seems that the code is otherwise relatively portable C ++, and indeed, it seems that the errors really start in _tmain anyway.

+3
source

The simplest answer will probably be to create it against winelib .

A better solution, though much more, is to place #ifdef WIN32 blocks around all specific Windows files and similarly to #ifdef LINUX around Linux implementations of the same functionality. This may require significant reorganization and reorganization.

+3
source

If you use _TCHAR, you also use other Windows-specific libraries on your computer. I already see QueryPerformanceCounter and QueryPerformanceFrequency (the first two methods of the Windows library I have ever used are actually. =]) Changing types will not lead you to the next step in finding functionality matching outside of Windows. Obviously, your source file has more than a thousand lines, but is there a fragment that you are wrapping that you could publish, or are you trying to make a large project?

0
source

I may be wrong, but you do not need to have windows.h to build btree or something like that. Find platform-independent code, or simply remove all these platform-specific calls like QueryPerformanceCounter , etc.

Or just get another good implementation of the B (or B +) tree based on the template. There are many of them, I can share mine if you want.

0
source

Source: https://habr.com/ru/post/1309171/


All Articles