|
You have to interpret the error information back to front:
1. The make error
Vaclav_ wrote: Makefile:5858: recipe for target 'gdbus/mainloop.lo' failed
tells you that the target mainloop.lo could not be built, and the messages above are output from the compiler that was called in an attempt to build this target.
2. The compiler output gives you accurate information on how it tried to expand a macro, resulting in C code that doesn't compile, and why it doesn't compile (negative array index).
3 The last lines of the compiler output show the condition that is statically checked, and ultimately leading to the compile error: as already pointed out, apparently the type unsigned long long does not have the same size as guint64 .
The output further above above shows how the static assert macro expansion turns the value of this condition (false) into an invalid array type definition, but that information is not neede or useful to you; you only need to know that an assertion failed, find out why this happened, and (how (or if) you can fix it.
4. The static assert was invoked in function _GLIB_CHECKED_ADD_U64 , and this function was called somewhere in mainloop.c (in line 28, according to the compiler). That means you should check the function call: maybe you're calling the wrong function for the job. Or maybe you shouldn't use guint64 for the target system you're compiling for.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Thanks, this is exactly what I was asking for.
All I wanted to know was answered in your first line.
I certainly appreciate you taking the time to walk thru the process.
I forgot to stress - this is not my code - it is a product of "make" produced with the aid of "configure" script which is part of canned "bluez" source code.
The "configure" is optioned to build "C" library, not to install "bulez" package, for ARM architecture. The "configure" and associated processes ( make and make install) are run on X86 architecture - hence "the problem".
All of this is "created" by autotools.
So I need to be careful not to "disturb" the code created by autotools.
Some of the code has very noticeable notes that "it was created bu autotools" , hence do not mess with it.
Cheers
|
|
|
|
|
It appears that the available source and 64 bit OS (I am using) is being confirmed as an issue.
I would hope if quint64 was "typedef" it would be in gtypes.h header. It is not there, maybe it is not needed to be "typedef".
I am still not sure why when (quint64) is used it is typecasted as "long long" when the define I found is just "long". I guess I need definition of "long" as used by glib code.
Perhaps I could just try to change the typecast to (unsigned long) but not sure why it would work.
What is really bothersome is that the comments in the header file clearly states "use the macros above " and not the failing function.
.
|
|
|
|
|
i want to call python function from c++. i copy the c++ and python code from this site. but when i try to compile c++ code then it show an error. the error is:
fetal error: python.h: no such file or directory
how can i solved this problem ?
|
|
|
|
|
Shohel hasan wrote: error: python.h: no such file or directory
how can i solved this problem ?
Be sure that "python.h" file exists!
|
|
|
|
|
Go back to the article where you copied the code from and check that the file python.h was also copied. If it is not there then post a question in the forum at the end of the article. The author should then be able to help you.
|
|
|
|
|
|
Hello everyone,
I'm sure it's been thought of various times before, but I'm waiting for a rebuild so this is more productive and self-entertaining than staring at the walls...
Just thinking about it without putting any really useful brain cells at risk, it would seem like it would kill two opposing birds with one stone. Lots of people hate having long namespaces used all over the place. Other people say it's a really bad thing because it can lead to clashes down the line and such. But an XML style scheme could work for both.
Any help will be appreciated.
|
|
|
|
|
Sounds completely pointless. It would be needlessly complicated to solve a non-existent problem.
|
|
|
|
|
david3217 wrote: hate having long namespaces
Having to type more is never a good reason to change anything. That's what you have autocompletion for. You should strive to write code that is easy to understand and manage. Writing less is not helping either. Using XML style will make your code harder to read and manage.
And if you really can't stand it, C++ already offers using . E. g. if you do a lot of I/O, you can write
using std::cout;
using std::endl;
using std::cin;
to abbreviate your code in your source file (never in a header file!). Not that it's really neccessary...
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Quote: Having to type more is never a good reason to change anything I disagree (I know, it is a matter of personal taste, anyway).
It is not just typing, but also reading back what you have (or some other developer has) typed. Think at progresses made in mathematics with the introduction of the symbolic notation (it is a far fetched example, but it gives you the idea).
|
|
|
|
|
If you type more, the resulting text should make your code more readable, not less. If it doesn't, that is an entirely different problem.
As a mathematician I do understand the advantage of short notation conventions. However, I also understand the problem of others not understanding your notation if they are not familiar with the shorthand notation you are using. So, if within your project team everyone agrees to certain shorthand notations, and actually take the time to document this (in case new members join the team), then the more power to you. Otherwise, just don't do it!
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Quote: If you type more, the resulting text should make your code more readable, not less Verbosity does not imply clarity. Often writing less makes your text more readable ("Je n'ai fait celle-ci plus longue que parce que je n'ai pas eu le loisir de la faire plus courte" ).
Quote: As a mathematician I do understand the advantage of short notation conventions. However, I also understand the problem of others not understanding your notation if they are not familiar with the shorthand notation you are using. So, if within your project team everyone agrees to certain shorthand notations, and actually take the time to document this (in case new members join the team), then the more power to you. Otherwise, just don't do it! I do agree with you on this (still, I believe that 'i' is a better name than 'index' ).
|
|
|
|
|
CPallini wrote: still, I believe that 'i' is a better name than 'index'
It depends...
In a very short for loop I usually prefer using 'i'.
However, if I fill in some listbox/listcontrol I prefer using 'index' or 'item' rather than 'i'.
|
|
|
|
|
The problem arises when you need to fill a listbox in a very short for loop. 
|
|
|
|
|
|
CPallini wrote: Verbosity does not imply clarity
That's why I said 'should'
CPallini wrote: (still, I believe that 'i' is a better name than 'index' )
I agree that 'index' is no more useful a name than 'i'. If there is any implied meaning to an index other than being the i'th element in a container, I prefer a variable name that reflects this meaning. For example if I have a curve consisting of several joined edges, I prefer 'edge_index' over 'i' or 'index'. Not only does this add clarity, it also makes my code extendable: if I later find I want to process each edge as a list of points, I have no problem naming the nested loop variable as 'point_index', and i wouldn't need to rename the existing loop variable.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
In Visual Studio 2019, the top level menu is placed in the top of the application (title bar).
AFAIK from what I can see from the MFC Project Wizard, there is no switch for that when creating a project (MDI/SDI template).
Is that another exclusive UI/UX component from Microsoft that we will never be able to use ?
I'd rather be phishing!
|
|
|
|
|
You can do it with raw Windows API but as MFC is only on maintenance it likely will never be available in MFC unless you do it yourself.
In vino veritas
|
|
|
|
|
The code can correctly display the bmp image that comes with the IDE, but can't display the image I added.
The IDE is visual studio 2012 and I use mfc to display bmp pictures.
This is the first piece of code in OnInitDialog():
static CImageList imgList;
imgList.Create(48,48,ILC_COLOR32,1,1);
imgList.Add(AfxGetApp()->LoadIcon(IDR_MAINFRAME));
m_List.SetImageList(&imgList,LVSIL_NORMAL);
m_List.InsertItem(0,_T("1th Test item"));
and the result of debug ——able to display the picture
while the second piece of code in OnInitDialog():
static CImageList imgList;
imgList.Create(40,48,ILC_COLOR32,1,1);
imgList.Add(AfxGetApp()->LoadIcon(IDB_BITMAP1));
m_List.SetImageList(&imgList,LVSIL_NORMAL);
m_List.InsertItem(0,_T("1th Test item"));
and the result of debug ——unable to display the picture,only blanks are displayed.
I am really sorry that I am a new man here and I do not know how to stick debug screenshots here.
|
|
|
|
|
tianzhili4399 wrote: static CImageList imgList;
imgList.Create(40,48,ILC_COLOR32,1,1);
imgList.Add(AfxGetApp()->LoadIcon(IDB_BITMAP1));
m_List.SetImageList(&imgList,LVSIL_NORMAL);
m_List.InsertItem(0,_T("1th Test item"));
Is the image IDB_BITMAP1 an icon or a bitmap? If it is a bitmap then you have to use CBitmap::LoadBitmap method (or LoadBitmap API function) instead.
BTW, what does the
AfxGetApp()->LoadIcon(IDB_BITMAP1) return?
|
|
|
|
|
I really appreciate you that I finally achieve my goal!Thank you very much!
|
|
|
|
|
You are welcome!
|
|
|
|
|
Hi,
I am converting C++ mpi program into C:
I am free() error because I am using malloc at several places. I have data stored in a file. The first line of the file tells about number of lines of data in the file. I am getting that error correct i.e. 3200.
I have also corrected several errors with the cooperation of code project's developers. I am testing my code with:
print statements followed by:
finalize();
return;
My code upto the point where I am getting invalid free() error is:
#include <stdio.h>
#include <math.h>
#include <mpi.h>
#include <time.h>
#include <stdlib.h>
//#include <vector.h>
//using namespace std;
// Sorts the input row into chunks to be scattered two all the processors.
void sortByProcess(/*vector<double>*/double* list1, double* list2, int count);
// Swaps two rows.
void swap(double** list, int count, int row1, int row2);
int rank, size;
int main(int argc, char * argv[])
{
double sTime, eTime, rTime;
/*ifstream*/ FILE* inFile;
int num_rows = 3200;
int num_cols = 3200;
int cur_control = 0;
double * send_buffer = NULL;
double * recv_buffer = NULL;
double ** data = NULL;
double determinant;
char strNum_rows[20];
/*vector<double>*/double* file_buffer;
// Just get the initialization of the program going.
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
// If the input file is not given, print message and exit.
if(argc < 2)
{
/*cout <<*/ printf("No input file given.\n");// << endl;
MPI_Finalize();
return 0;
}
// If the root node (0), then open the input file and read in the
// number of rows.
if(!rank)
{
printf("After rank inside if @@@@@");
inFile = fopen(argv[1], "r");
fgets(strNum_rows, 20, inFile);
num_rows = atoi(strNum_rows);
printf("num_rows???? =%d",num_rows);
file_buffer = malloc(num_rows * sizeof(int));
/*???? inFile.open(argv[1]);
inFile >> num_rows;
file_buffer.resize(num_rows);*/
}
//printf("After rank outside @@@@@@@@#");
send_buffer = (double *)malloc(num_rows * sizeof(double));
/*?????send_buffer = new double[num_rows];*/
//printf("After send_buffer #####@");
// Broadcasts the number of rows to each processor.
MPI_Bcast (&num_rows, 1, MPI_INT, 0, MPI_COMM_WORLD);
num_cols = num_rows / size;
// Allocate the memory on each processor.
//printf("After Bcast #####@");
data = (double **) malloc(num_cols * sizeof(double *));
/*???? data #####@");*/
for(int i = 0; i < num_cols; i++)
data[i] = (double *) malloc(num_rows * sizeof(double));
/* ??? data[i] = new double[num_rows]; */
for(int i = 0; i < num_cols; i++)
{
for(int j = 0; j < num_rows; j++)
data[i][j] = 0;
}
//printf("Before recv_buffer $$$$$$$@");
recv_buffer = (double *) malloc(num_cols * sizeof(double));
/*???? recv_buffer = new double[num_cols];*/
// Scatter the data.
for(int i = 0; i < num_rows; i++)
{
if(!rank)
{
for(int j = 0; j < num_rows; j++){
fgets(strNum_rows, 20, inFile);
file_buffer[j] = atof(strNum_rows);
}
/*????? inFile >> file_buffer[j];*/
sortByProcess(file_buffer, send_buffer, num_rows);
}
//printf("After sortByProcess ^^^^^^@");
// Scatters the data so that each process gets the next value for their columns.
MPI_Scatter(send_buffer, num_cols, MPI_DOUBLE, recv_buffer, num_cols, MPI_DOUBLE, 0, MPI_COMM_WORLD );
for(int j = 0; j < num_cols; j++)
{
data[j][i] = recv_buffer[j];
}
}
//printf("After Scatter ^^^^^^@");
/*delete []*/
free(recv_buffer);
/*delete []*/
free(send_buffer);
// Begin timing.
MPI_Barrier(MPI_COMM_WORLD);
sTime = MPI_Wtime();
printf("After Barrier ^^^^^^@");
MPI_Finalize();
return 0;
The error which I am getting is:
$ mpicc gaussian.c
$ mpirun -np 4 ./a.out matrix.3200.txt
free(): invalid size
[lc2530hz:08268] *** Process received signal ***
[lc2530hz:08268] Signal: Aborted (6)
[lc2530hz:08268] Signal code: (-6)
[lc2530hz:08268] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20)[0x7f107b56af20]
[lc2530hz:08268] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f107b56ae97]
[lc2530hz:08268] [ 2] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f107b56c801]
[lc2530hz:08268] [ 3] /lib/x86_64-linux-gnu/libc.so.6(+0x89897)[0x7f107b5b5897]
[lc2530hz:08268] [ 4] /lib/x86_64-linux-gnu/libc.so.6(+0x9090a)[0x7f107b5bc90a]
[lc2530hz:08268] [ 5] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4dc)[0x7f107b5c3e2c]
[lc2530hz:08268] [ 6] ./a.out(+0x1056)[0x564381392056]
[lc2530hz:08268] [ 7] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f107b54db97]
[lc2530hz:08268] [ 8] ./a.out(+0xbda)[0x564381391bda]
[lc2530hz:08268] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 0 with PID 0 on node lc2530hz exited on signal 6 (Aborted).
--------------------------------------------------------------------------
$
Somebody please guide me how to remove this error.
Zulfi.
|
|
|
|
|
Something, somewhere is corrupting one of your malloc() blocks. First off, I count 5 calls to malloc() , but only 2 calls to free() in the code given. That's unlikely to be the source of your problem here, but it does mean you have a memory leak, unless that memory is freed up elsewhere.
Since you have 2 calls to free() and a hex stack dump, we don't know which free() is causing the problem. In order to get better data on where and why you have the corruption first compile your program with debug info enabled. Google suggests that you should be able to pass the -g flag to mpicc. You might also want to use the -o <file-name> option to write the output to file-name instead of a.out e.g. mpicc -g gaussian.c -o gaussian
There is an excellent tool to help debug memory allocation problems available for linux called valgrind. Once again a little googling about suggest that the way to run valgrind with mpirun is
mpirun -n 2 valgrind --tool=memcheck ./a.out
You may need to figure out how to install valgrind on your system.
Update: you can send the output from valgrind to a log file using --logfile=vg_log.%p , which would send the valgrind output to a file vg_log.1479 , where 1479 is the process id of the running program. AIUI, you would get a vg_log.nnnn for each process spawned by mpirun. Take a look at the man page for valgrind and/or see the online documentation for further info.
|
|
|
|
|