Tag Archives: debug

[Solved] Error: error C2601: ‘b‘ : local function definitions are illegal error C2063: ‘b‘ : not a function

Scene:

In general, this problem may be that a "}" is missing
There is also a small probability that your C++standard library is C++98 or earlier, which does not support non built-in initialization list writing.


the Situation of Missing ‘}’

We can see that if our test1 method is short of one}, all subsequent functions will report errors. We need to check it carefully

Solution
Check for yourself that the first line of code near the line number that reports the error is missing a }.

C++ standard does not support
When your C++ standard is C++98, the initialization list of C++98 does not support the initialization list methods of non-built-in types. This can be seen in the following code

#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main()
{
	int a[] = { 1, 2, 3 };

	int b[] {1, 2, 3};
	vector<int> v{1,5,5};
	map<int, float> m{{1, 2.f}, {2, 3.2f}};

	return 0;
}

编译结果:

Solution:
Then in this case your non-built-in type variables will have to be initialized using other methods

[Solved] Error:E0415 no suitable constructor exists to convert from “int“ to “Rational“

Scene:

The problem is that the constructor for is missing or is declared as explicit.

Please refer to the following scenario.

#include <iostream>

using std::cout;
using std::endl;

class Rational1
{
public:
	Rational1(int n = 0, int d = 1):num(n), den(d)
	{
		cout << __func__ << "(" << num << "/" << den << ")" << endl;
	}

public:
	int num; 
	int den;
};

class Rational2
{
public:
	explicit Rational2(int n = 0, int d = 1) :num(n), den(d)
	{
		cout << __func__ << "(" << num << "/" << den << ")" << endl;
	}

public:
	int num;
	int den;
};

void Display1(Rational1 r)
{
	cout << __func__ << endl;
}

void Display2(Rational2 r)
{
	cout << __func__ << endl;
}


int main()
{
	Rational1 r1 = 11;
	Rational1 r2(11);
	Rational2 r3 = 11; // error E0415
	Rational2 r4(11);

	Display1(1);
	Display2(2); // error  E0415
	return 0;
}

Explicit keyword

1. Specifies that the constructor or conversion function (from C++11) is explicit, that is, it cannot be used for implicit conversion and copy initialization
2. Explicit can be used with constant expressions The function is explicit if and only if the constant expression evaluates to true (From C++20)

Problem description

Error:E0415 no suitable constructor exists to convert from “int“ to “Rational“

Solution:

1. Implement the corresponding constructor yourself. (Recommended)
2. Delete the constructor modified by the explicit keyword. (Not recommended)

[Solved] error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘

Error log

Text

Octal value is out of range

1> E:\CProject\test12\Source. c(5,10): error C2041: illegal digit ‘8’ for base ‘8’

Hexadecimal value is out of range

1> E:\CProject\test12\Source. c(5,10): error C2059: syntax error: ‘bad suffix on number’
1> E:\CProject\test12\Source. c(5,10): error C2153: integer literals must have at least one digit
1> E:\CProject\test12\Source. c(5,13): error C2021: expected exponent value, not ‘;’
1> E:\CProject\test12\Source. c(5,10): warning C4244: ‘initializing’: conversion from ‘double’ to ‘int’, possible loss of data
1> Done building project “test12.vcxproj” – FAILED.

Screenshot (hexadecimal value exceeds the range)

Solution:

C2041 series error: this kind of number, which is generally octal or hexadecimal, is out of range
for example:

  1. 09; because there is no 9 in octal
  2. 0xq; because hex doesn’t have the q character.

This requires us to carefully check whether the relevant figures exceed the range.

[Solved] fatal error C1189: #error: STL1003: Unexpected compiler, expected C++ compiler

Error Log:

screenshot

text version:

F:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\yvals_core.h(23,1): fatal error C1189: #error: STL1003: Unexpected compiler, expected C++ compiler.
F:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\yvals_core.h(23,1): fatal error C1189: #error: STL1003: Unexpected compiler, expected C++ compiler.

 

Error

Solution:
This problem is because the C++ header file is referenced in the C file. Just replace cmath with math.h.

[Solved] Vue2.x vue-lazyload Error: Failed to resolve directive: lazy

Today, I want to realize the lazy loading of pictures. After registering components according to the tutorial, the console will report an error as above

The version in package.json is found to be the default downloaded version 3.0.0-rc.2

Solution:

Try to modify the version to 1.3.3

"dependencies": {
    "axios": "^0.27.2",
    "core-js": "^3.8.3",
    "element-ui": "^2.15.9",
    "vue-lazyload": "^1.3.3",
    "vue": "^2.6.14",
    "vue-router": "^3.1.3"
  },

Run, no more errors!

[Solved] RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dim

Error Messages:
tensor.sub_(mean[:, None, None]).div_(std[:, None, None])
RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0

Error Reason:
Dimensional information mismatch

Original Code:

image = Image.open(image_path)

After modification:

image = Image.open(image_path).convert('RGB')

How to Solve MacOS ffmpeg killed Error


tags: MacOS Debug Tips

Question

Recently, I wanted to download the live playback course in nailing with the tried and true method, but some errors suddenly appeared when executing ffmpeg on the command line:

[1]    40344 killed     ffmpeg

 

Solution:

This problem can be solved by compiling and installing from the source code through the following command

brew tap homebrew-ffmpeg/ffmpeg
brew install homebrew-ffmpeg/ffmpeg/ffmpeg

At this time, enter ffmpeg in the terminal to get:

❯ ffmpeg
ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers
  built with Apple clang version 13.1.6 (clang-1316.0.21.2)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.0-with-options_2 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --enable-opencl --enable-videotoolbox --enable-neon --disable-htmlpages
  libavutil      57. 17.100/57. 17.100
  libavcodec     59. 18.100/59. 18.100
  libavformat    59. 16.100/59. 16.100
  libavdevice    59.  4.100/59.  4.100
  libavfilter     8. 24.100/ 8. 24.100
  libswscale      6.  4.100/ 6.  4.100
  libswresample   4.  3.100/ 4.  3.100
  libpostproc    56.  3.100/56.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

How to Solev PyEddyTracker geostrophic current calculation Error

Error message

Call add_uv_lagerloef() function in pyEddyTracker==3.5.0  reports an error:

numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<built-in function sub>) found for signature:
 
 >>> sub(UniTuple(int64 x 2), float64)
 
There are 12 candidate implementations:
   - Of which 10 did not match due to:
   Overload of function 'sub': File: <numerous>: Line N/A.
     With argument(s): '(UniTuple(int64 x 2), float64)':
    No match.
   - Of which 2 did not match due to:
   Operator Overload in function 'sub': File: unknown: Line unknown.
     With argument(s): '(UniTuple(int64 x 2), float64)':
    No match for registered cases:
     * (int64, int64) -> int64
     * (int64, uint64) -> int64
     * (uint64, int64) -> int64
     * (uint64, uint64) -> uint64
     * (float32, float32) -> float32
     * (float64, float64) -> float64
     * (complex64, complex64) -> complex64
     * (complex128, complex128) -> complex128
During: typing of intrinsic-call at D:\Miniconda3\envs\dl\lib\site-packages\py_eddy_tracker\generic.py (570)
File "D:\Miniconda3\envs\dl\lib\site-packages\py_eddy_tracker\generic.py", line 570:
def nearest_grd_indice(x, y, x0, y0, xstep, ystep):
    <source elided>
    return (
        numba_types.int32(round(((x - x0[0]) % 360.0)/xstep)),
        ^
python-BaseException
Backend TkAgg is interactive backend. Turning interactive mode on.

Temporary Solution:
Find add_uv_lagerloef() function in ~/.conda/envs/dl/lib/python3.7/site-packages/py_eddy_tracker/dataset/grid.py line 1700:
Modify:

    def add_uv_lagerloef(self, grid_height, uname="u", vname="v", schema=15):
        self.add_uv(grid_height, uname, vname)
        latmax = 5
        # _, (i_start, i_end) = self.nearest_grd_indice((0, 0), )
        i_start, i_end = (((-latmax, latmax) - self.y_bounds[0])/self.ystep).round().astype('int32')  # debug from numba
        sl = slice(i_start, i_end)
        # Divide by sideral day
        lat = self.y_c[sl]
        gob = (
            cos(deg2rad(lat))
            * ones((self.x_c.shape[0], 1))
            * 4.0
            * pi
           /(23 * 3600 + 56 * 60 + 4.1)
           /self.EARTH_RADIUS
        )
        with errstate(divide="ignore"):
            gob = self.GRAVITY/(gob * ones((self.x_c.shape[0], 1)))
        mode = "wrap" if self.is_circular() else "reflect"

        # fill data to compute a finite difference on all point
        data = self.convolve_filter_with_dynamic_kernel(
            grid_height,
            self.kernel_bessel,
            lat_max=10,
            wave_length=500,
            order=1,
            extend=0.1,
        )
        data = self.convolve_filter_with_dynamic_kernel(
            data, self.kernel_bessel, lat_max=10, wave_length=500, order=1, extend=0.1
        )
        data = self.convolve_filter_with_dynamic_kernel(
            data, self.kernel_bessel, lat_max=10, wave_length=500, order=1, extend=0.1
        )
        v_lagerloef = (
            self.compute_finite_difference(
                self.compute_finite_difference(data, mode=mode, schema=schema),
                mode=mode,
                schema=schema,
            )[:, sl]
            * gob
        )
        # u_lagerloef = (
        #     -self.compute_finite_difference(
        #         self.compute_finite_difference(data, vertical=True, schema=schema),
        #         vertical=True,
        #         schema=schema,
        #     )[:, sl]
        #     * gob
        # )
        u_lagerloef = (
            -self.compute_finite_difference(
                self.compute_finite_difference(data, mode=mode, schema=schema),
                mode=mode,
                schema=schema,
            )[:, sl]
            * gob
        )
        w = 1 - exp(-((lat/2.2) ** 2))
        self.vars[vname][:, sl] = self.vars[vname][:, sl] * w + v_lagerloef * (1 - w)
        self.vars[uname][:, sl] = self.vars[uname][:, sl] * w + u_lagerloef * (1 - w)

1 line 1703Don’t use numba to calculate i_start, i_end

	# _, (i_start, i_end) = self.nearest_grd_indice((0, 0), )
	i_start, i_end = (((-latmax, latmax) - self.y_bounds[0])/self.ystep).round().astype('int32')

2 line 1743 fix the problem that the generated ugos is missing

        # u_lagerloef = (
        #     -self.compute_finite_difference(
        #         self.compute_finite_difference(data, vertical=True, schema=schema),
        #         vertical=True,
        #         schema=schema,
        #     )[:, sl]
        #     * gob
        # )
        u_lagerloef = (
            -self.compute_finite_difference(
                self.compute_finite_difference(data, mode=mode, schema=schema),
                mode=mode,
                schema=schema,
            )[:, sl]
            * gob
        )

[Solved] C++ Compile Error: prerequisites are different [How to Solve]

Scene

When adding new x.h/x.hpp/X.C/x.cpp files to the UE4 project, even if there are no other files to include these new files, the following errors may appear during compilation (both build and rebuild):
unrealbuildtool prerequisites are different
this error occurs when the x.obj file is compiled, but the link operation cannot be performed correctly

reason

As the name suggests, there is no problem with the code itself, but that the code block cannot be integrated into the existing project. UE4 has preprocessing on the path for the include file. If the path name of the file is duplicate, this problem will occur. For example:

1. Proto/error.pb.h already exists under module 

2. try to add Server/XXServer/proto/error.pb.h

According to the include rule of UE4, #include "proto/error.Pb.H" may point to two files at the same time (when the files in the server/xxserver directory are imported), so it cannot be judged accurately, and an error is reported during compilation.

Note: unrealbuildtool under Windows does not judge case, and the paths of proto/and proto/are the same

Solution:

    directory paths should not overlap. Try to avoid the path with the same name.
    1. There should be no files with the same name under the path

 

[Solved] original_keras_version = f.attrs[‘keras_version‘].decode(‘utf8‘)

windows system:
original_keras_version = f.attrs[‘keras_version’].decode(‘utf8’)
1. error:

load_weights_from_hdf5_group
    original_keras_version = f.attrs['keras_version'].decode('utf8')

AttributeError: 'str' object has no attribute 'decode'

2. Cause analysis

When installing tensorflow, the default installed h5py is 3.1.0, and an error is reported because the TF you installed does not support an excessively high version of h5py

3. Solutions

1. Uninstall h5py3 Version 1.0, installing h5py2.0 Version 10.0.2. Restart the compiler

pip install h5py==2.10.0

[Solved] “error_code“:500,“message“:“IO Error trying to forward REST request: java.net.ConnectException: Connection Refused

“error_code”:500,“message”:“IO Error trying to forward REST request: java.net.ConnectException: Connection refused”
An error is reported by executing the following command.
curl -u debezium:4a3s4d02234 http://debezium-001.optics.net:8083/connectors/mysql-optics-prod/restart -X POST
The error message is shown below.
{“error_code”:500, “message”: “IO Error trying to forward REST request: java. ConnectException: Connection refused”}
Solution: make sure the following parameters are set correctly.
rest.host.name=debezium-001.optics.netrest.port=8083

[Solved] PYNQ load bit error: KeyError: ‘interrupts‘

Problem Description:

In the BD diagram of vivado, the interrupted direct connection between my IP and PS Core

An error occurs when loading the bit file generated by vivado in pynq

Solution:

Add a concat block in the connection between PS and our own IP interrupt line, as shown in the figure below

finally, the bit file can be successfully loaded in pynq

and the final program can output correct results