473,811 Members | 3,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

incompatible warning in C/C++

Ali
incompatible warning in C/C++

I am using MS Visual C/C++ 6.0. I get the following warning when compiling

C:model.ex.c(12 21) : warning C4133: '=' : incompatible types - from
'struct s_lsp_def *' to 'struct s_lsp_def *'
In the .h file, I have
=============== =======

typedef struct s_lsp_def;

typedef struct
{
int lsp_id;
int priority;
struct s_lsp_def* ptr_next_lsp_de f;
}s_lsp_def;

in a .c file, model.ex.c, I have
=============== =============== ==

int bcModel_add_lsp ToList ( s_lsp_def* the_ptr_lsp_def ,
{

s_lsp_def* curr_ptr_lsp_de f;

// the following line is the PROBLEM

curr_ptr_lsp_de f->ptr_next_lsp_d ef = the_ptr_lsp_def ;
}
Does anyone understand why this warning.
Thanks.


Dec 20 '05 #1
9 2560

Ali wrote:
incompatible warning in C/C++

I am using MS Visual C/C++ 6.0. I get the following warning when compiling

C:model.ex.c(12 21) : warning C4133: '=' : incompatible types - from
'struct s_lsp_def *' to 'struct s_lsp_def *'
In the .h file, I have
=============== =======

typedef struct s_lsp_def;

typedef struct
{
int lsp_id;
int priority;
struct s_lsp_def* ptr_next_lsp_de f;
}s_lsp_def;

in a .c file, model.ex.c, I have
=============== =============== ==

int bcModel_add_lsp ToList ( s_lsp_def* the_ptr_lsp_def ,
{

s_lsp_def* curr_ptr_lsp_de f;

// the following line is the PROBLEM

curr_ptr_lsp_de f->ptr_next_lsp_d ef = the_ptr_lsp_def ;
}
Does anyone understand why this warning.
Thanks.

Try the following instead:
typedef struct
{
int lsp_id;
int priority;
s_lsp_def* ptr_next_lsp_de f;
}s_lsp_def;

You don't need the struct, since you're doing a typedef

Dec 20 '05 #2
Ali wrote:
incompatible warning in C/C++
There is no such thing as "C/C++". It's either C or it is C++. Find out
which and then post to the right newsgroup. If what you do is in fact C,
post to comp.lang.c. Post here again if it is (unlikely) C++.
[...]


V
Dec 20 '05 #3
Axter wrote:
[..]
Try the following instead:
typedef struct
{
int lsp_id;
int priority;
s_lsp_def* ptr_next_lsp_de f;
}s_lsp_def;

You don't need the struct, since you're doing a typedef


In C++ you don't need any typedef. You simply write

struct s_lsp_def
{
...
s_lsp_def *ptr;
};

V
Dec 20 '05 #4
Axter wrote:
Ali wrote:
incompatible warning in C/C++

I am using MS Visual C/C++ 6.0. I get the following warning when compiling

C:model.ex.c(12 21) : warning C4133: '=' : incompatible types - from
'struct s_lsp_def *' to 'struct s_lsp_def *'
In the .h file, I have
=============== =======

typedef struct s_lsp_def;

typedef struct
{
int lsp_id;
int priority;
struct s_lsp_def* ptr_next_lsp_de f;
}s_lsp_def;

in a .c file, model.ex.c, I have
=============== =============== ==

int bcModel_add_lsp ToList ( s_lsp_def* the_ptr_lsp_def ,
{

s_lsp_def* curr_ptr_lsp_de f;

// the following line is the PROBLEM

curr_ptr_lsp_de f->ptr_next_lsp_d ef = the_ptr_lsp_def ;
}
Does anyone understand why this warning.
Thanks.

Try the following instead:
typedef struct
{
int lsp_id;
int priority;
s_lsp_def* ptr_next_lsp_de f;
}s_lsp_def;

You don't need the struct, since you're doing a typedef

Yes, but you can't use the typedef inside its own definition. But you
can use the incomplete struct type itself. You just need to name it
before using it, like so:

typedef struct s_lsp_def
{
int lsp_id;
int priority;

struct s_lsp_def* ptr_next_lsp_de f;

} s_lsp_def;
This is valid in both C and C++. In C++ you don't need the typedef,
because a struct name works like a class name, so you can always use it
without putting 'struct' in front of it.

C++ only:

struct s_lsp_def
{
int lsp_id;
int priority;

s_lsp_def* ptr_next_lsp_de f;

};
Dec 20 '05 #5
"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:%%******** ***********@new sread1.mlpsca01 .us.to.verio.ne t...
Ali wrote:
incompatible warning in C/C++


There is no such thing as "C/C++". It's either C or it is C++. Find out
which and then post to the right newsgroup. If what you do is in fact C,
post to comp.lang.c. Post here again if it is (unlikely) C++.
[...]


V


Actually, since c++ allows C code, I think your statement is a bit
misleading Victor.

I've seen "There is no such thing as "C/C++" too many times on this
newsgroup and it is quite obvious what that the poster means "in C or
C++...".

Have you no concept of what / means?
Dec 21 '05 #6

Jim Langston wrote:
"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:%%******** ***********@new sread1.mlpsca01 .us.to.verio.ne t...
Ali wrote:
incompatible warning in C/C++


There is no such thing as "C/C++". It's either C or it is C++. Find out
which and then post to the right newsgroup. If what you do is in fact C,
post to comp.lang.c. Post here again if it is (unlikely) C++.
[...]


V


Actually, since c++ allows C code, I think your statement is a bit
misleading Victor.

I've seen "There is no such thing as "C/C++" too many times on this
newsgroup and it is quite obvious what that the poster means "in C or
C++...".

Have you no concept of what / means?


I have no concept of what "in C or in C++" means. They are different
languages and solutions to the same problem in one language are often
inappropriate or even incorrect in the other. So whether you say "in
C/C++" or in "in C or in C++" you are probably doing so because you
don't realise that, either way, it's a meaningless question.

The use of "C/C++" seems to me to imply some muddled thinking along the
lines of " I know they are kind of different but C++ is just a better C
so they are basically the same thing". In which case, correcting that
muddles thinking, as I think Victor did, is helpful.

Gavin Deane

Dec 21 '05 #7

Victor Bazarov wrote:
Ali wrote:
incompatible warning in C/C++
There is no such thing as "C/C++". It's either C or it is C++. Find out
which and then post to the right newsgroup. If what you do is in fact C,
post to comp.lang.c. Post here again if it is (unlikely) C++.
[...]


V


It is true there is no such language as C/C++ however you might want to
write header files that are compatible with both languages, as both
languages have the concept of a header file.
typedef struct s_lsp_def;


Is that a valid forward declaration? typedef struct s_lsp_def to what?
Presumably you want to say that s_lsp_def is a typedef to an unknown
struct. I don't think that's allowed although it would be nice if it
were.

Now to answer the original problem, if you want to use the
struct/typedef features that is used in C then you should give the
struct a name, maybe s_lsp_def_tag. Then you can use that also within
the struct itself thus:

typedef struct s_lsp_def_tag
{
// code including a pointer to its own type
} s_lsp_def;

although I don't think you could use s_lsp_def for a forward
declaration.

Dec 21 '05 #8
"Jim Langston" <ta*******@rock etmail.com> writes:
"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:%%******** ***********@new sread1.mlpsca01 .us.to.verio.ne t...
Ali wrote:
incompatible warning in C/C++


There is no such thing as "C/C++". It's either C or it is C++. Find out
which and then post to the right newsgroup. If what you do is in fact C,
post to comp.lang.c. Post here again if it is (unlikely) C++.
[...]


V


Actually, since c++ allows C code, I think your statement is a bit
misleading Victor.


I think the statement above is more than a bit misleading.

A c++ compiler compiles C++ code. A c compiler compiles c code. C++
does *not* compile C code.

Try the following in your favorite c++ compiler:

struct class
{
enum { zero, one, two, three } new;
};

int main(void)
{
struct class throw;
return 0;
}

Or the following:

#include <stdlib.h>

int main(void)
{
int *x = malloc(1000 * sizeof *x);
/* do something useful with x */
free(x);
return 0;
}

/Niklas Norrthon

Dec 21 '05 #9
Earl Purple wrote:
Victor Bazarov wrote:
typedef struct s_lsp_def;

I didn't write that.
Is that a valid forward declaration? typedef struct s_lsp_def to what?
Presumably you want to say that s_lsp_def is a typedef to an unknown
struct. I don't think that's allowed although it would be nice if it
were.
You should simply write

struct s_lsp_def;

At least in C++ it's a valid forward-declaration of 's_lsp_def' as
a struct (class).
[..]


V
Dec 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
17768
by: Brian Stubblefield | last post by:
Dear clc members, I am rather new to the C programming language. I have a rather large program that I am currently debugging. Currently, the following snippet of code in the c program: char skillkey; char (*fillkey_ptr)= skillkey;
7
593
by: Brian Stubblefield | last post by:
Dear clc members, I am new to C and am posting several messages concerning a large C program that I am debugging. I am encountering a "incompatible types in assignment" warning for the following code during the compile stage: #include <stdio.h> #include <signal.h>
15
9358
by: Chris Readle | last post by:
Hi all, Somewhat new to C and I'm getting the following error from my latest code. Here's the warning I'm getting: chris_readle_project3_assignment3.c: In function `main': chris_readle_project3_assignment3.c:23: warning: passing arg 1 of `displaySales' from incompatible pointer type And here is the code in question:
1
2872
by: Josh Wilson | last post by:
Hey gang, So I have my stdin which is user defined file, and am wanting to write it to a temporary file (seems odd I know, but there is a sincere reason), and then use that file as the stdin for the remaining part of the program. I have combed the FAQ and got some preliminary questions answered, and tried to model this after what I have seen suggested to people previously, but for my strcpy and freopen I get, "warning: passing arg 1 of...
7
90268
by: Paminu | last post by:
On a gentoo linux system i don't get any warnings when I comlpile this code: #include <stdio.h> typedef struct test { void *content; struct test_ *bob; } test_;
6
5274
by: PraZ | last post by:
Hi all. Here is a simple code, which when compiled with gcc results in the warning "incompatible pointer type" for arg 1, as expected. But this is just what I want to do, because it makes it easy for me to handle the single dimensional stream I have as a multidimensional array inside the function func(). Now, I am just wondering if there is a way by which I can disable this incompatible pointer type warning in gcc. Any suggestions?
8
3272
by: Michael | last post by:
Hi all, why do I get a message: warning: passing arg 1 of `collectInput' from incompatible pointer type In 'main' have: char inputString; collectInput(&inputString);
1
1519
by: wanglei0214 | last post by:
I compiles a program in SLOS, but there is a warning i donot know how to remove? here is the framework of the code: typedef struct device_tree { ...... union {
0
4931
by: srikar | last post by:
Hi all, I am having a problem, when I am compiling the code in 32 bit option on a 64 bit machine using the macro CPPFLAGS= -m32 I am getting the following warnings from the linker . /`../bin/amd64_stat_gnu_02015/WriteFault.o' is incompatible with i386:x86-64 output /usr/bin/ld: warning: i386 architecture of input file `../bin/amd64_stat_gnu_02015/WriteLogic.o' is incompatible with i386:x86-64 output /usr/bin/ld: warning: i386...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10405
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4342
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.