473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Compilation Failed: warning: data definition has no type or storage class

Ced
Hi,

i'm not an expert in C but i try to compile BTNG software under linux
kernel 2.4.2-2. I get these errors at the very first stage. Does
someone could have a rapid look on this and tell me what's wrong

regards
I get this error:

dmemory.h:66: parse error before `mem2ulong'
dmemory.h:66: warning: data definition has no type or storage class
dmemory.h:66: parse error before `ulong'
dmemory.h:71: parse error before `mem2uint'
dmemory.h:71: warning: data definition has no type or storage class
dmemory.h:71: parse error before `uint'

Here is the dmemory.h:

/* Beholder RMON ethernet network monitor,Copyright (C) 1993 DNPAP
group */
/* See file COPYING 'GNU General Public Licence' for copyright details
*/
#ifndef _DMEMORY_H
#define _DMEMORY_H
#include <dnpap.h>
#ifndef HAS_UINT
typedef unsigned int uint;
#endif
#ifndef HAS_ULONG
typedef unsigned long ulong;
#endif
typedef WORD word;
typedef DWORD dword;
typedef LWORD lword;

#ifndef HAS_MEMMOVE
#define memmove(dst, src, n) bcopy((src), (dst), (n));
#endif
#define protconvtype(type) type mem2##type(BYTE *mem); \
void type##2mem(BYTE *mem, type val)

#ifdef ALIGNSECURE

#define defconvtype(type) \
type mem2##type(BYTE *mem) \
{ \
type val; \
\
memcpy(&val, mem, sizeof(type)); \
return val; \
} \
\
void type##2mem(BYTE *mem, type val) \
{ \
memcpy(mem, &val, sizeof(type)); \
}

#else

#define defconvtype(type) \
type mem2##type(BYTE *mem) \
{ \
return *(type *)mem; \
} \
\
void type##2mem(BYTE *mem, type val) \
{ \
*(type *)mem = val; \
}

#endif

#ifdef SPECIAL_MEMCMP
int memcmp(CONST VOID *b1, CONST VOID *b2, ULONG len);
#endif

protconvtype(long);
protconvtype(ulong);
protconvtype(word);
protconvtype(dword);
protconvtype(lword);
protconvtype(int);
protconvtype(uint);
#endif
Nov 14 '05 #1
4 25346
"Ced" <d_********@yahoo.com> wrote in message
news:e8**************************@posting.google.c om...
Hi,

i'm not an expert in C but i try to compile BTNG software under linux
kernel 2.4.2-2. I get these errors at the very first stage. Does
someone could have a rapid look on this and tell me what's wrong

regards
I get this error:

dmemory.h:66: parse error before `mem2ulong'
dmemory.h:66: warning: data definition has no type or storage class
dmemory.h:66: parse error before `ulong'
dmemory.h:71: parse error before `mem2uint'
dmemory.h:71: warning: data definition has no type or storage class
dmemory.h:71: parse error before `uint'

Here is the dmemory.h:

/* Beholder RMON ethernet network monitor,Copyright (C) 1993 DNPAP
group */
/* See file COPYING 'GNU General Public Licence' for copyright details
*/
#ifndef _DMEMORY_H
#define _DMEMORY_H
#include <dnpap.h>
#ifndef HAS_UINT
typedef unsigned int uint;
#endif
#ifndef HAS_ULONG
typedef unsigned long ulong;
#endif
typedef WORD word;
typedef DWORD dword;
typedef LWORD lword;

#ifndef HAS_MEMMOVE
#define memmove(dst, src, n) bcopy((src), (dst), (n));
#endif
#define protconvtype(type) type mem2##type(BYTE *mem); \
void type##2mem(BYTE *mem, type val)

#ifdef ALIGNSECURE

#define defconvtype(type) \
type mem2##type(BYTE *mem) \
{ \
type val; \
\
memcpy(&val, mem, sizeof(type)); \
return val; \
} \
\
void type##2mem(BYTE *mem, type val) \
{ \
memcpy(mem, &val, sizeof(type)); \
}

#else

#define defconvtype(type) \
type mem2##type(BYTE *mem) \
{ \
return *(type *)mem; \
} \
\
void type##2mem(BYTE *mem, type val) \
{ \
*(type *)mem = val; \
}

#endif

#ifdef SPECIAL_MEMCMP
int memcmp(CONST VOID *b1, CONST VOID *b2, ULONG len);
#endif

protconvtype(long);
protconvtype(ulong);
protconvtype(word);
protconvtype(dword);
protconvtype(lword);
protconvtype(int);
protconvtype(uint);
#endif


I'd venture to say that both HAS_UINT and HAS_ULONG are defined macros and
yet you do not have a (native, or otherwise) typedef for uint or ulong.

If you undefine both macros so that the code uses the inline typedefs at
lines 13 and 16, what happens?
Nov 14 '05 #2


Ced wrote:
Hi,

i'm not an expert in C but i try to compile BTNG software under linux
kernel 2.4.2-2. I get these errors at the very first stage. Does
someone could have a rapid look on this and tell me what's wrong

regards
I get this error:

dmemory.h:66: parse error before `mem2ulong'
dmemory.h:66: warning: data definition has no type or storage class
dmemory.h:66: parse error before `ulong'
dmemory.h:71: parse error before `mem2uint'
dmemory.h:71: warning: data definition has no type or storage class
dmemory.h:71: parse error before `uint'

Here is the dmemory.h:

/* Beholder RMON ethernet network monitor,Copyright (C) 1993 DNPAP
group */
/* See file COPYING 'GNU General Public Licence' for copyright details
*/
#ifndef _DMEMORY_H
#define _DMEMORY_H


If you're going to ask people for help debugging an error message that
refers to line numbers, it'd be courteous to provide the file with line
numbers especially when you're posting lines that are long enough to be
wrapped by many viewers. It would probably also encourage people to
consider your problem.

Ed.

Nov 14 '05 #3
Ced a pensé très fort :
Hi,

i'm not an expert in C but i try to compile BTNG software under linux
kernel 2.4.2-2. I get these errors at the very first stage. Does
someone could have a rapid look on this and tell me what's wrong


Well, the code you provide is not for absolute beginners.
Here is a working solution with comments (-ed-), an implementation file
(dmemory.c) and a (minimum) test file (main.c).

Note that I have modified dmemory.h, and that I have probably broken
some GPL rule...

/* dmemory.h */

/* Beholder RMON ethernet network monitor,Copyright (C) 1993 DNPAP
group */
/* See file COPYING 'GNU General Public Licence' for copyright details
*/
#ifndef _DMEMORY_H
#define _DMEMORY_H

/* -ed-
Unknown header. Removed.
#include <dnpap.h>
*/

/* -ed- missing definitions. 4 lines added (arbitrary definitions) */
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned long LWORD;

#ifndef HAS_UINT
typedef unsigned int uint;
#endif
#ifndef HAS_ULONG
typedef unsigned long ulong;
#endif
typedef WORD word;
typedef DWORD dword;
typedef LWORD lword;

/* -ed- memmove() is standard.
* (no idea what bcopy() is)
* 2 lines added
*/
#include <string.h>
#define HAS_MEMMOVE

#ifndef HAS_MEMMOVE
#define memmove(dst, src, n) bcopy((src), (dst), (n));
#endif

/* -ed- This is hard ro read
#define protconvtype(type) type mem2##type(BYTE *mem);
\
void type##2mem(BYTE *mem, type val)
* What about
*/
#define protconvtype(type) \
type mem2##type(BYTE *mem); \
void type##2mem(BYTE *mem, type val)

#ifdef ALIGNSECURE

#define defconvtype(type) \
type mem2##type(BYTE *mem) \
{ \
type val; \
\
memcpy(&val, mem, sizeof(type)); \
return val; \
} \
\
void type##2mem(BYTE *mem, type val) \
{ \
memcpy(mem, &val, sizeof(type)); \
}

#else

#define defconvtype(type) \
type mem2##type(BYTE *mem) \
{ \
return *(type *)mem; \
} \
\
void type##2mem(BYTE *mem, type val) \
{ \
*(type *)mem = val; \
}

#endif

#ifdef SPECIAL_MEMCMP
int memcmp(CONST VOID *b1, CONST VOID *b2, ULONG len);
#endif

protconvtype(long);
protconvtype(ulong);
protconvtype(word);
protconvtype(dword);
protconvtype(lword);
protconvtype(int);
protconvtype(uint);

#endif

/* dmemory.c */

#include "dmemory.h"

/* implementations */
defconvtype(long);
defconvtype(ulong);
defconvtype(word);
defconvtype(dword);
defconvtype(lword);
defconvtype(int);
defconvtype(uint);

/* main.c */

#include "dmemory.h"

#include <stdio.h>

int main (void)
{
BYTE mem[32] = {0};

word val = 0x1234;

printf ("data = %lX (before)\n", (unsigned long) val);

word2mem (mem, val);

val= mem2word (mem);

printf ("data = %lX (after)\n", (unsigned long) val);

return 0;
}

The result:

D:\CLC\C\CED>bc
data = 1234 (before)
data = 1234 (after)

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"

Nov 14 '05 #4
Groovy hepcat Ced was jivin' on 22 Jul 2004 07:41:42 -0700 in
comp.lang.c.
Compilation Failed: warning: data definition has no type or storage
class's a cool scene! Dig it!
I get this error:

dmemory.h:66: parse error before `mem2ulong'
dmemory.h:66: warning: data definition has no type or storage class
dmemory.h:66: parse error before `ulong'
dmemory.h:71: parse error before `mem2uint'
dmemory.h:71: warning: data definition has no type or storage class
dmemory.h:71: parse error before `uint'
I get all of these:

testing.c(9): Error! E1055: Unable to open 'dnpap.h'
testing.c(18): Error! E1022: Missing or misspelled data type near
'WORD'
testing.c(19): Error! E1022: Missing or misspelled data type near
'DWORD'
testing.c(20): Error! E1022: Missing or misspelled data type near
'LWORD'
testing.c(67): Error! E1009: Expecting ',' but found '*'
testing.c(67): Error! E1116: An id list not allowed except for
function definition
testing.c(67): Error! E1009: Expecting ',' or ';' but found 'mem'
testing.c(67): Error! E1009: Expecting ',' but found '*'
testing.c(67): Error! E1116: An id list not allowed except for
function definition
testing.c(68): Error! E1009: Expecting ',' but found '*'
testing.c(68): Error! E1116: An id list not allowed except for
function definition
testing.c(68): Error! E1009: Expecting ',' or ';' but found 'mem'
testing.c(68): Error! E1009: Expecting ',' but found '*'
testing.c(68): Error! E1116: An id list not allowed except for
function definition
testing.c(69): Error! E1009: Expecting ',' but found '*'
testing.c(69): Error! E1116: An id list not allowed except for
function definition
testing.c(69): Error! E1009: Expecting ',' or ';' but found 'mem'
testing.c(69): Error! E1009: Expecting ',' but found '*'
testing.c(69): Error! E1116: An id list not allowed except for
function definition
testing.c(70): Error! E1009: Expecting ',' but found '*'
testing.c(70): Error! E1147: Too many errors: compilation aborted
Error: Compiler returned a bad status compiling 'testing.c'
Here is the dmemory.h:

/* Beholder RMON ethernet network monitor,Copyright (C) 1993 DNPAP
group */
/* See file COPYING 'GNU General Public Licence' for copyright details
*/
#ifndef _DMEMORY_H
#define _DMEMORY_H
Invades implementation name space. Avoid identifiers beginning with
underscores. (I take it you didn't write this code. In that case, I
can't blame you for this. But just bare it in mind for the future.)
#include <dnpap.h>
Non-standard header.
#ifndef HAS_UINT
typedef unsigned int uint;
#endif
#ifndef HAS_ULONG
typedef unsigned long ulong;
#endif
typedef WORD word;
typedef DWORD dword;
typedef LWORD lword;
Non-standard types.
#ifndef HAS_MEMMOVE
#define memmove(dst, src, n) bcopy((src), (dst), (n));
#endif
This is utterly pointless, since memmove() is a standard function
and bcopy() isn't.
#define protconvtype(type) type mem2##type(BYTE *mem); \
void type##2mem(BYTE *mem, type val)
Ye gads! Not only is the above macro incredibly ugly, but it is also
wrong. In the second half of this macro, the ## operator will join the
two tokens "type" (after it has been macro expanded) and "2", leaving
the token "mem" hanging. This is the cause of your problem.
#ifdef ALIGNSECURE

#define defconvtype(type) \
type mem2##type(BYTE *mem) \
{ \
type val; \
\
memcpy(&val, mem, sizeof(type)); \
return val; \
} \
\
void type##2mem(BYTE *mem, type val) \
Same problem here.
{ \
memcpy(mem, &val, sizeof(type)); \
}

#else

#define defconvtype(type) \
type mem2##type(BYTE *mem) \
{ \
return *(type *)mem; \
} \
\
void type##2mem(BYTE *mem, type val) \
{ \
*(type *)mem = val; \
}

#endif

#ifdef SPECIAL_MEMCMP
int memcmp(CONST VOID *b1, CONST VOID *b2, ULONG len);
#endif
Pointless again, since memcmp() is standard.
protconvtype(long);
Now, let's examine what happens here, armed with an understanding of
the protconvtype macro. This line expands to this:

long mem2type(BYTE *mem); \
void long2mem(BYTE *mem, long val);

Tidied up it looks like this:

long mem2long(BYTE *mem);
void long2 mem(BYTE *mem, long val);

Now, you see that this sequence of characters, "2mem", is parsed as
the two tokens "2" and "mem", not a single token. Thus, upon expansion
of the above macro invocation, the sequence "type##2mem" is parsed as
"type ## 2 mem", and the result (after expansion of type) is "long2
mem".
protconvtype(ulong);
protconvtype(word);
protconvtype(dword);
protconvtype(lword);
protconvtype(int);
protconvtype(uint);


Of course, the same applies for all of these.

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
Nov 14 '05 #5

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

Similar topics

2
by: Gaubitzer Erwin | last post by:
Hi everybody I want to recompile the DISLIN graphics module for Python under Linux, because I think it is one of the best graphics libraries at present. The included module was for version 2.0...
8
by: Scott J. McCaughrin | last post by:
The following program compiles fine but elicits this message from the linker: "undefined reference to VarArray::funct" and thus fails. It seems to behave as if the static data-member:...
3
by: Dan | last post by:
Hi, I have a problem using an aspx page with a Control on it. I get the following error message Compiler Error Message: CS1595: 'Test.Class2' is defined in multiple places; using definition...
1
by: Arsalan Ahmad | last post by:
Hi all, I am trying to compile some source files using makefile. While compiling I am getting errors as shown below. Any idea how can I solve this problem. I believe I need to add some...
9
by: subramanian | last post by:
Hello. Consider the following code fragment : enum TestEnum { val1 = 10, val2 = 100, val3 = 1000 }; class Test { public : enum TestEnum { val1 = 1, val2 val3 }; Test(int i = 0, int j = 0,...
1
by: hamardk | last post by:
Hi, I'm trying to compile log4cpp-0.3.5rc3 on : SunOS belaurora 5.9 Generic_118558-11 sun4u sparc SUNW,Ultra-4 I'm having compilation issues which are: In file included from...
1
by: dewi | last post by:
Dear All, I am trying to compile a C code using Visual C++. Can anyone explain how to solve it? Thank You. #include <math.h> #include <string.h> #include "RV2AJFRONT_NEW.h" #include...
2
by: BruceWho | last post by:
I downloaded boost1.35.0 and built it with following command: bjam --toolset=msvc-7.1 --variant=release --threading=multi -- link=shared --with-system stage and it failed to compile, error...
20
by: jacob navia | last post by:
Consider this code static typedef struct { int boo; } FOO; This provokes with MSVC: ------------------------------ Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.762 for x64...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.