Category : visual-c++

I am compiling the following code with c++17: #include <iostream> struct A { void barA() const {std::cout << "barAn";} }; struct B { void barB() const {std::cout << "barBn";} }; template<typename T> constexpr bool isBaseA() { return std::is_base_of<A, T>::value; } template<typename T> constexpr bool isBaseB() { return std::is_base_of<B, T>::value; } template<typename… Args> class K : ..

Read more

I am refactoring a big legacy project. It used to link libraries within its source files via #pragma comment(lib, "lib_name.lib"). Once I’ve moved #pragma comment(lib, "mmc.lib") from the .cpp file to .vcxproj, I started receiving multiple definitions linker error: 1>uafxcwd.lib(afxstate.obj) : error LNK2005: "public: __cdecl AFX_MAINTAIN_STATE2::~AFX_MAINTAIN_STATE2(void)" ([email protected]@[email protected]) already defined in mmc.lib(apimfc.obj) I couldn’t find the ..

Read more

I have a code like that: const uint64_t tsc = __rdtsc(); const __m128 res = computeSomethingExpensive(); const uint64_t elapsed = __rdtsc() – tsc; printf( "%" PRIu64 " cycles", elapsed ); In release builds, this prints garbage like “38 cycles” because VC++ compiler reordered my code: const uint64_t tsc = __rdtsc(); 00007FFF3D398D00 rdtsc 00007FFF3D398D02 shl rdx,20h ..

Read more

I’ve written a template function whose template arguments are being correctly deduced by GCC/Clang but are ambiguous to MSVC. Here is a compiler explorer link: https://godbolt.org/z/8b376EYYr The template is declared as: template <typename Int = int, template <typename…> typename Cont = std::vector> Cont<Int> input_to_int(Cont<std::string> input); and it is used in main(): std::vector<int> int_vec = input_to_int(str_vec); ..

Read more

While testing some things regarding page faults I discovered a curious difference between how new operates in Debug mode and Release mode in MSVC. Consider the following code1: #include <array> constexpr size_t PAGE_SIZE = 4096; int main() { const size_t count = 1000000; char* const mem = new char[PAGE_SIZE * count]; // page align the ..

Read more

I got such error with the message: TestBufferQueue.obj : error LNK2019: unresolved external symbol "void __cdecl GenerateAndEnqueueItems<class QueueItem,15>(int,class common::bufferqueue<class QueueItem,15> &)" ([email protected]@@[email protected]@@[email protected]@@[email protected]@[email protected]@@Z) referenced in function "private: virtual void __thiscall TestClear_ClearsMultipleElements_Test::TestBody(void)" ([email protected][email protected]@EAEXXZ) My code. Header file Helpers.h: #pragma once // includes skipped QueueItem* GenerateQueueItem(); template <typename T, int size> void GenerateAndEnqueueItems(int, common::bufferqueue<T, size>&); Cpp file Helpers.cpp: ..

Read more

I am trying to send the data using Rs232c to Toshiba TOSNUC CNC. While sending data less then 40 lines, data passes without any error but in case more than 40 lines, few line were missing. how to resolved it. serial comm. setting:- baudRate- 4800, Databits- 7, Parity-Even, StopBits-2, DtrEnable-True, DiscardNull-True, Handshake- requestToSend, RtsEnable-true, Error ..

Read more