473,761 Members | 2,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"extern struct foobar" linux compilation warning

All,

I am receiving the following compilation error on LINUX
(but not Solaris, HPUX, WIN32, etc):

compiling osr.c
LBFO.h(369): warning #64: declaration does not declare anything
extern struct foobar;
^

This is apparently a forward reference to a data structure
for the purposes of declaring a pointer to this opaque
structure.

Any ideas how to get rid of this warning???

Thanks in advance!
Rick
Nov 14 '05 #1
10 3516
BTW: This is the "icc" (intel compiler) *not*
gcc...

It appears -fms_extensions compiler option is not supported.

FYI

Thanks!
Rick
Nov 14 '05 #2
In message <Xn************ *************** *******@148.87. 1.53>
Rick Anderson <Ri************ **@oracle.com> wrote:
I am receiving the following compilation error on LINUX
(but not Solaris, HPUX, WIN32, etc):

compiling osr.c
LBFO.h(369): warning #64: declaration does not declare anything
extern struct foobar;
^

This is apparently a forward reference to a data structure
for the purposes of declaring a pointer to this opaque
structure.

Any ideas how to get rid of this warning???


Remove the "extern". It's meaningless unless you're actually declaring an
object, which you're not. You're merely naming a structure type.

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1728 727430
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
Nov 14 '05 #3
Rick Anderson wrote:
All,

I am receiving the following compilation error on LINUX
(but not Solaris, HPUX, WIN32, etc):

compiling osr.c
LBFO.h(369): warning #64: declaration does not declare anything
extern struct foobar;
^
extern struct foobar baz;

would make sense.

struct foobar;

can make sense.
"extern" goes with objects, not with types.

This is apparently a forward reference to a data structure
for the purposes of declaring a pointer to this opaque
structure.
Is it?

If it is really necessary to get something opaque,
use void *:

typedef void * FooBarHandle;

The user gets only the handle and even a look at the
typedef does not tell how and where information is stored.
If the user can be trusted to not circumvent your access
macros and functions (and your data structures are not
top secret), the header file giving the type definition
for "struct foobar" should be included.
Any ideas how to get rid of this warning???


Heal the code.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 14 '05 #4
In message <39************ *@individual.ne t>
Michael Mair <Mi**********@i nvalid.invalid> wrote:
If it is really necessary to get something opaque,
use void *:

typedef void * FooBarHandle;

The user gets only the handle and even a look at the
typedef does not tell how and where information is stored.
If the user can be trusted to not circumvent your access
macros and functions (and your data structures are not
top secret), the header file giving the type definition
for "struct foobar" should be included.


I beg to differ. I'd prefer

typedef struct foobar *FooBarHandle;

leaving the contents of struct foobar opaque. That gives you a bit more type
safety - someone can't accidentally give you a BarHandle instead of a
FooBarHandle.

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1728 727430
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
Nov 14 '05 #5
Kevin Bracey wrote:
In message <39************ *@individual.ne t>
Michael Mair <Mi**********@i nvalid.invalid> wrote:

If it is really necessary to get something opaque,
use void *:

typedef void * FooBarHandle;

The user gets only the handle and even a look at the
typedef does not tell how and where information is stored.
If the user can be trusted to not circumvent your access
macros and functions (and your data structures are not
top secret), the header file giving the type definition
for "struct foobar" should be included.

I beg to differ. I'd prefer

typedef struct foobar *FooBarHandle;

leaving the contents of struct foobar opaque. That gives you a bit more type
safety - someone can't accidentally give you a BarHandle instead of a
FooBarHandle.


You are right, at least for the application at hand.

I was thinking of completely opaque information where you do not
even want the people to know what kind of type may be underlying,
i.e. if the type in question is an array, structure or whatever
-- in this case, one obviously does not want type safety.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 14 '05 #6
Kevin Bracey wrote:
Michael Mair <Mi**********@i nvalid.invalid> wrote:
If it is really necessary to get something opaque,
use void *:

typedef void * FooBarHandle;

The user gets only the handle and even a look at the
typedef does not tell how and where information is stored.
If the user can be trusted to not circumvent your access
macros and functions (and your data structures are not
top secret), the header file giving the type definition
for "struct foobar" should be included.


I beg to differ. I'd prefer

typedef struct foobar *FooBarHandle;

leaving the contents of struct foobar opaque. That gives you a
bit more type safety - someone can't accidentally give you a
BarHandle instead of a FooBarHandle.


Exactly what I was mulling how to express, when I decided to look
onwards and see what others had said about it. void* allows you to
receive and pass pointers of unknown types and purpose onward
freely, but this is not such a case.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Nov 14 '05 #7
Kevin Bracey wrote:

I beg to differ. I'd prefer

typedef struct foobar *FooBarHandle;

leaving the contents of struct foobar opaque. That gives you a bit more type
safety - someone can't accidentally give you a BarHandle instead of a
FooBarHandle.


Definitely better than a void *, but really not necessary. As long as

struct foobar;

is declared, pointers to struct foobar can be freely passed around, but
not dereferenced.

--
=============== =============== =============== =============== ============
Ian Pilcher i.*******@comca st.net
=============== =============== =============== =============== ============
Nov 14 '05 #8
Ian Pilcher <i.*******@comc ast.net> wrote in
news:QN******** ************@co mcast.com:
Kevin Bracey wrote:
Definitely better than a void *, but really not necessary. As long as

struct foobar;

is declared, pointers to struct foobar can be freely passed around,
but not dereferenced.


That works great - thanks!
Rick
Nov 14 '05 #9
In message <QN************ ********@comcas t.com>
Ian Pilcher <i.*******@comc ast.net> wrote:
Kevin Bracey wrote:

I beg to differ. I'd prefer

typedef struct foobar *FooBarHandle;

leaving the contents of struct foobar opaque. That gives you a bit more
type safety - someone can't accidentally give you a BarHandle instead of
a FooBarHandle.


Definitely better than a void *, but really not necessary. As long as

struct foobar;

is declared, pointers to struct foobar can be freely passed around, but
not dereferenced.


Ah, but making it a typedef hides the fact the handle is a struct from the
basic API. One might want (for whatever reason) to change the handle from an
int to a structure or vice-versa.

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1728 727430
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
Nov 14 '05 #10

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

Similar topics

3
1968
by: Christopher M. Lusardi | last post by:
Hello, THE PROBLEM ----------- If I compile parts of my program with CC, and C, using extern "C" as appropriate it compiles without any errors, but it does a segmentation fault when I run the program. The variables involved in the segmentation fault are surrounded by compiler directives. I am 100% sure that I do not have to extern "C"
22
6027
by: Ian | last post by:
The title says it all. I can see the case where a function is to be called directly from C, the name mangling will stuff this up. But I can't see a reason why a template function can't be given extern "C" linkage where it is to be assigned to a C function pointer. Ian
9
8256
by: tropostropos | last post by:
On Solaris, using the Sun compiler, I get annoying warnings from the following code. The problem is that I am passing a C++ member function pointer to the C library function qsort. Is there a solution? Declaring the function extern "C" fails, because linkage declarations must be made at file scope. #include <stdlib.h> //for qsort template <class T> class Sorter
11
9425
by: Daniele Benegiamo | last post by:
Is the following program standard-compliant? I've compiled it with some compilers and no errors or warnings are produced, but this is not a demonstration. The "incriminated" part is the declaration: extern "C" struct X; that is then defined as:
10
6193
by: Mark A. Gibbs | last post by:
I have a question about mixing C and C++. In a C++ translation unit, I want to define a function with internal linkage and C calling convention. Here's a sample of what I want to do: // main.cpp // This is defined in a C module extern "C" void fake_qsort(void*, std::size_t, std::size_t, int (*compare)(const void*, const void*));
0
1163
by: Lei Jiang | last post by:
I have setup a .NET library in C++ language in VS.NET 2005 Beta1. I this project, I add some additional dependency to some C library. The header file of the C library has been marked as "extern "C"", but the linker just can't find these function entries. After I read the error report carefully, I found that the compiler seems ignored these "extern C" mark. The linker report : Error 13 error LNK2020: unresolved token (0A00001A) "void...
4
4757
by: kk_oop | last post by:
Hi. I need to write a C++ callback function and register it with a C program. I've read that this can be done if the callback function is a static method. I've also read that I should use a global function with the extern "C" prefix. I was leaning toward using the static method approach until I saw a posting that said compatibility between static C++ functions and C is not guaranteed in the respective language standards. This made me...
5
1936
by: jchludzinski | last post by:
I have 3 files (see below: a.h, w.c, ww.c). I would like to use a single x (declared somewhere) which would global to both compilation units: w.c & ww.c. No matter where I place the "extern" qualifier - it appears to work: x is shared between w.c and ww.c. Or if I simple don't use "extern", it works. Why? What is the correct (or simply preferred) usage? ---John PSI'm using gcc (GCC) 4.0.2.
13
2090
by: arnuld | last post by:
this is the code: ------------------------------------------------------------------------- #include <iostream> #include <string> #include <vector> struct Pair { std::string name;
0
9336
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
9948
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...
0
9765
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
8770
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...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6603
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
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.