Stig30rus 0 / 0 / 1 Регистрация: 04.12.2014 Сообщений: 140 |
||||
1 |
||||
19.10.2018, 17:08. Показов 10919. Ответов 3 Метки нет (Все метки)
Делаю по книге Герберта Штилдта https://www.rulit.me/books/c-b… 8-165.html А тут такое. Все никак не получается исправить.
0 |
zss Модератор 13252 / 10391 / 6213 Регистрация: 18.12.2011 Сообщений: 27,793 |
||||||||
19.10.2018, 17:29 |
2 |
|||||||
Решение1.
strcpy_s(s, ob.s); Эта функция требует указания размера s
2. Для такого присвоения нужно дополнительно перегрузить
1 |
TheCalligrapher Вездепух 10916 / 5911 / 1615 Регистрация: 18.10.2014 Сообщений: 14,859 |
||||||||||||
19.10.2018, 17:36 |
3 |
|||||||||||
Эта функция требует указания размера s
Тогда уже
Но, разумеется, такое использование Добавлено через 1 минуту
2. Для такого присвоения нужно дополнительно перегрузить
Скорее нужно исправить уже перегруженный.
1 |
Stig30rus 0 / 0 / 1 Регистрация: 04.12.2014 Сообщений: 140 |
||||
19.10.2018, 17:58 [ТС] |
4 |
|||
А тут как?
UPD — Понял strcpy_s(s, strlen(str) + 1, str);
0 |
Не понимаю, откуда эта ошибка появляется. Уже изучил, почему она может вызываться, но мне это никак не помогло в поиске/решении проблемы. Что надо сделать?
Код с реализацией функций:
#pragma once
#include <vector>
#include <iostream>
#include <random>
template <typename T>
void create_huge_matrix(std::vector<std::vector<T>>& matrix, T lowerLimit);
template <typename T>
void create_freeMatrixColumn(std::vector<T>& freeMatrixColumn);
template <typename T>
inline void create_huge_matrix(std::vector<std::vector<T>>& matrix, T lowerLimit)
{
//std::vector<std::vector<T>> huge_matrix;
std::random_device random_device; // Источник энтропии
std::mt19937 generator(random_device()); // Генератор случайных чисел
std::uniform_int_distribution<> distribution(lowerLimit, lowerLimit * 2);
for (int i = 0; i < matrix[0].size(); i++)
{
for (int j = 0; j < matrix[0].size(); j++)
{
if (i == j) matrix[i][j] = distribution(generator);
else matrix[i][j] = rand() % 2;
}
}
}
template <typename T>
inline void create_freeMatrixColumn(std::vector<T> &freeMatrixColumn)
{
for (int i = 0; i < size; i++)
freeMatrixColumn[i] = (rand() % 100) / 10;
}
Часть кода из функции main.cpp (где вызываю/есть ошибка):
#include <iostream>
#include <vector>
#include <cmath>
#include "gauss_serial.h"
#include "gauss_parallel.h"
#include "huge_matrix.h"
bool check_answer(std::vector<double> answer, std::vector<double> freeMatrixCloumn, std::vector<std::vector<double>> matrix);
void create_new_freeColumn(std::vector<double>& v, std::vector<double>& answer, std::vector<std::vector<double>> matrix);
void keep_4_digits_after_point(std::vector<double>& v);
int main()
{
setlocale(LC_ALL, "utf-8");
int m; // количество строк
int n; // количество столбцов
double value; // значение элемента массива
std::vector<std::vector<double>> matrix_s, matrix_p, matrixForChecking; // матрица элементов без столбца свободных членов
std::vector<double> freeMatrixColumn_s, freeMatrixColumn_p, freeMatrixColumnForChecking; // столбец свободных членов
printf("Решение СЛАУ методом Гауссаn");
// Задаём размерность матрицы
printf("Укажите размерность матрицыn");
printf("Количество строк: ");
std::cin >> m;
matrix_s.resize(m);
matrix_p.resize(m);
matrixForChecking.resize(m);
printf("Количество столбцов: ");
std::cin >> n;
create_huge_matrix(matrix_s, 5);
create_huge_matrix(matrix_p);
create_huge_matrix(matrixForChecking);
DisplayMap.insert(i, map[i]);
As you can see in the above sample, I’ve tried to use the insert function, but it keeps displaying the same E0304 Error, which is for an overloaded function. In VS2019, the error details are:
Severity Code Description Project File Line Suppression State
Error (active) E0304 no instance of overloaded function "std::basic_string<_Elem, _Traits, _Alloc>::insert [with _Elem=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" matches the argument list
The error says that the arguments don’t match because the different overloads have different arguments.
Can you help me solve this error?
Here’s my full code if you need it:
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <Windows.h>
#include <conio.h>
#include <algorithm>
#include <string>
#include "Data.h"
using namespace std;
int main() {
SetConsoleDisplayMode(GetStdHandle(STD_OUTPUT_HANDLE), CONSOLE_FULLSCREEN_MODE, 0);
CONSOLE_SCREEN_BUFFER_INFO csbi;
int WindowColumns, WindowRows, DisplayBuffer;
string DisplayMap;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
WindowColumns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
WindowRows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
cout << WindowColumns << "," << WindowRows;
DisplayBuffer = WindowColumns * WindowRows;
for (int i = 0; i < WindowColumns; i++) {
DisplayMap.insert(i, map[i]);
}
return 0;
}
Thanks In advance.
EDIT:
Data.h here:
#pragma once
#include <iostream>
#include <String>
using namespace std;
string savedMap = " "
" "
" "
" "
" ";
string map = savedMap;
int w = 119, a = 97, s = 115, d = 100;
char key_press;
int myPOS = 35;
int MDPOS = myPOS, ascii_value;
Please don’t ask me why I use the namespace std in a header file.
DisplayMap.insert(i, map[i]);
As you can see in the above sample, I’ve tried to use the insert function, but it keeps displaying the same E0304 Error, which is for an overloaded function. In VS2019, the error details are:
Severity Code Description Project File Line Suppression State
Error (active) E0304 no instance of overloaded function "std::basic_string<_Elem, _Traits, _Alloc>::insert [with _Elem=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" matches the argument list
The error says that the arguments don’t match because the different overloads have different arguments.
Can you help me solve this error?
Here’s my full code if you need it:
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <Windows.h>
#include <conio.h>
#include <algorithm>
#include <string>
#include "Data.h"
using namespace std;
int main() {
SetConsoleDisplayMode(GetStdHandle(STD_OUTPUT_HANDLE), CONSOLE_FULLSCREEN_MODE, 0);
CONSOLE_SCREEN_BUFFER_INFO csbi;
int WindowColumns, WindowRows, DisplayBuffer;
string DisplayMap;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
WindowColumns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
WindowRows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
cout << WindowColumns << "," << WindowRows;
DisplayBuffer = WindowColumns * WindowRows;
for (int i = 0; i < WindowColumns; i++) {
DisplayMap.insert(i, map[i]);
}
return 0;
}
Thanks In advance.
EDIT:
Data.h here:
#pragma once
#include <iostream>
#include <String>
using namespace std;
string savedMap = " "
" "
" "
" "
" ";
string map = savedMap;
int w = 119, a = 97, s = 115, d = 100;
char key_press;
int myPOS = 35;
int MDPOS = myPOS, ascii_value;
Please don’t ask me why I use the namespace std in a header file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
#include <iostream> #include <iomanip> #include <functional> #include <vector> #include <boost/multiprecision/cpp_bin_float.hpp> using namespace boost::multiprecision; using namespace std; typedef number<cpp_bin_float<200>> cpp_dec_float_unlim; #define double cpp_dec_float_unlim double dy0dt(const double& t, const double& y_0, const double& y_1, const double& y_2, const double& y_3, double& alpha) { return double(8.85e4) - y_2*y_0*((double(0.2) - y_0) / (double(1.) - y_1)) + y_0 / double(1e-8); } double dy1dt(const double& t, const double& y_0, const double& y_1, const double& y_2, const double& y_3, double& alpha) { return y_0 * y_2; } double dy2dt(const double& t, const double& y_0, const double& y_1, const double& y_2, const double& y_3, double& alpha) { return y_0 * y_3; } double dy3dt(const double& t, const double& y_0, const double& y_1, const double& y_2, const double& y_3, double& alpha) { return double(1e30)*sqrt(y_0)*exp(double(-alpha) / y_0); } struct my_data { double t, y_0, y_1, y_2, y_3; my_data(double _t, double _y0, double _y1, double _y2, double _y3) : t(_t), y_0(_y0), y_1(_y1), y_2(_y2), y_3(_y3) {} }; void rungeKutta( double y0, double y1, double y2, double y3, double t0, double max_t, double h, double alpha, std::vector<my_data>& result){ double k1[4], k2[4], k3[4], k4[4]; double t = t0; std::vector<std::function<double(double, double, double, double, double, double) >> vfunc; vfunc.push_back(dy0dt); vfunc.push_back(dy1dt); vfunc.push_back(dy2dt); vfunc.push_back(dy3dt); for (int i = 0; i < ((max_t - t0) / h); i++) { std::cout << t << "t" << std::setprecision(5) << y0 << "t" << y1 << "t" << y2 << "t" << y3 << std::endl; for (int j = 0; j < 4; ++j) { k1[j] = h*vfunc[j](t, y0, y1, y2, y3, alpha); } for (int j = 0; j < 4; ++j) { k2[j] = h*vfunc[j](t + double(0.5)*h, y0 + double(0.5)*k1[0], y1 + double(0.5)*k1[1], y2 + double(0.5)*k1[2], y3 + double(0.5)*k1[3], alpha); } for (int j = 0; j < 4; ++j) { k3[j] = h*vfunc[j](t + double(0.5)*h, y0 + double(0.5)*k2[0], y1 + double(0.5)*k2[1], y2 + double(0.5)*k2[2], y3 + double(0.5)*k3[3], alpha); } for (int j = 0; j < 4; ++j) { k4[j] = h*vfunc[j](t + h, y0 + k3[0], y1 + k3[1], y2 + k3[2], y3 + k3[3], alpha); } y0 += (k1[0] + double(2.) * k2[0] + double(2.) * k3[0] + k4[0]) / double(6.); y1 += (k1[1] + double(2.) * k2[1] + double(2.) * k3[1] + k4[1]) / double(6.); y2 += (k1[2] + double(2.) * k2[2] + double(2.) * k3[2] + k4[2]) / double(6.); y3 += (k1[3] + double(2.) * k2[3] + double(2.) * k3[3] + k4[3]) / double(6.); t = t + h; } result.emplace_back(t, y0, y1, y2, y3); } void foo() { double y_0, y_1, y_2, y_3, alpha; std::cout << "Input y_0: "; std::cin >> y_0; // 1e-10 std::cout << "Input y_1: "; std::cin >> y_1; // 0 std::cout << "Input y_2: "; std::cin >> y_2; // 0 std::cout << "Input y_3: "; std::cin >> y_3; // 0 std::cout << "Input alpha: "; std::cin >> alpha; //0.25 double beg_time, max_time; std::cout << "Input beg_time: "; std::cin >> beg_time; // 0 cout << "Input max_time: "; std::cin >> max_time; // 1.1e-8 double step; cout << "Input step: "; std::cin >> step; // 1e-9 vector<my_data> result; cout << "Runge-Kutta method: " << endl; rungeKutta(y_0, y_1, y_2, y_3, beg_time, max_time, step, alpha, result); double a, b, e, xmin; cout << "Input a: "; cin >> a; // 8e-2 cout << "Input b: "; cin >> b; // 5e-1 cout << "Input eps: "; cin >> e; // 1e-3 cout << "Gold method: " << endl; Gold(a, b, e, xmin); cout << endl; } /******************************************************************************************************************/ int main(){ foo(); system("pause"); return 0; } |
So we have this old project that was originally written in MSVC 6.0. The language standards are mostly C-based, although we’ve moved the project over to C++ v17 on VS2017. This project compiled just fine before the latest VS update.
After updating VS to 15.7.0 (and adding the Windows 10 SDK 10.0.17134), the project will still compile, but Intellisense drops hundreds of E0304 errors like the following:
Severity Code Source Description Error (active) E0304 IntelliSense no instance of function template "__countof_helper" matches the argument list
Every single one of these calls (or at least every one I looked at) was calling
_countof like this snippet:
TCHAR ErrMsg[ERR_MSG_SIZE] = { (TCHAR)NULL }; ... FormatErrorString(GetLastError(), ErrMsg, _countof(ErrMsg), true);
If I try to «Show Error Help» on the error in the error list, it does nothing.
Has anyone else run into this or have some advice on why or how this has occurred?
Additionally, if it helps…
This project is:
— Targeting Windows 10 as a platform
— 10.0.17134.0 as the Windows SDK Version
— has 64-bit config (UNICODE defined) and 32-bit config (UNICODE
not defined) profiles
— using «C++ 17 Standard» as the C++ Language Standard
— does not use MFC or CLR
I can include all the miscellaneous options if that helps, but I think that covers the major variables. Some of these options are intentional due to certain constraints in our software environment and/or integration requirements.
Thanks for any feedback.
Recommended Posts
-
- Report
- Share
Hello friend, I am super beginner. I am trying to run this example code http://www.asic-world.com/systemc/first1.html#Counter_Design_Specs counter design and counter testbench on my systemc with visual studio. So I got two error. Here I put the error together.
-
Severity Code Description Project File Line Suppression State
Error (active) E0304 no instance of overloaded function «sc_start» matches the argument list Project1 C:Users60182sourcereposProject1Project1first_counter_tb.cpp 17
-
Severity Code Description Project File Line Suppression State
Error C2665 ‘sc_core::sc_start’: none of the 4 overloads could convert all the argument types Project1 c:users60182sourcereposproject1project1first_counter_tb.cpp 17
- Quote
Link to comment
Share on other sites
-
- Report
- Share
The example you are refering to is for SystemC 2.0 and more over has errors. Actually this is a bad example to start with.
- the sc_start() in line 17 needs to be commented out for 2 reasons: a) it doesn’t make any sense and b) it runs elaboration and tracing (VCD) needs to be initialized before that. After elaboration you cannot add signals for tracing anymore
-
sc_start() (lines 32, 34, 40, 42, 47, 49, 56 58) has to be called either without any arguments (so it runs to the end) or with a duration in terms of sc_time like this:
sc_start(1, SC_NS);
My recommendation would be to either use the Doulus tutorials: https://www.doulos.com/knowhow/systemc/tutorial/ or the stuff from SCLive (https://sclive.wordpress.com/)
-
maehne
-
1
- Quote
Link to comment
Share on other sites
Join the conversation
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
DisplayMap.insert(i, map[i]);
As you can see in the above sample, I’ve tried to use the insert function, but it keeps displaying the same E0304 Error, which is for an overloaded function. In VS2019, the error details are:
Severity Code Description Project File Line Suppression State
Error (active) E0304 no instance of overloaded function "std::basic_string<_Elem, _Traits, _Alloc>::insert [with _Elem=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" matches the argument list
The error says that the arguments don’t match because the different overloads have different arguments.
Can you help me solve this error?
Here’s my full code if you need it:
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <Windows.h>
#include <conio.h>
#include <algorithm>
#include <string>
#include "Data.h"
using namespace std;
int main() {
SetConsoleDisplayMode(GetStdHandle(STD_OUTPUT_HANDLE), CONSOLE_FULLSCREEN_MODE, 0);
CONSOLE_SCREEN_BUFFER_INFO csbi;
int WindowColumns, WindowRows, DisplayBuffer;
string DisplayMap;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
WindowColumns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
WindowRows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
cout << WindowColumns << "," << WindowRows;
DisplayBuffer = WindowColumns * WindowRows;
for (int i = 0; i < WindowColumns; i++) {
DisplayMap.insert(i, map[i]);
}
return 0;
}
Thanks In advance.
EDIT:
Data.h here:
#pragma once
#include <iostream>
#include <String>
using namespace std;
string savedMap = " "
" "
" "
" "
" ";
string map = savedMap;
int w = 119, a = 97, s = 115, d = 100;
char key_press;
int myPOS = 35;
int MDPOS = myPOS, ascii_value;
Please don’t ask me why I use the namespace std in a header file.