473,507 Members | 8,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Issues with LibMad

I have Turbo C 2.0, and in layer3.c, a variable called mantisa is
defined as:

unsigned long mantisa: 27;

The compiler says that the bit width is too large. How do I fix the
code so I can compile it?

regards,

ja******@netzero.net
Nov 14 '05 #1
11 2248

"Quackker12" <ja******@netzero.net> wrote in message news:1e**************************@posting.google.c om...
I have Turbo C 2.0, and in layer3.c, a variable called mantisa is
defined as:

unsigned long mantisa: 27;

Is mantisa a member of a structure? If not, then it's illegal to
define/declare bit-fields like this.
The compiler says that the bit width is too large. How do I fix the
code so I can compile it?

regards,

ja******@netzero.net


Nov 14 '05 #2

"Vijay Kumar R Zanvar" <vi*****@globaledgesoft.com> wrote in message news:2i************@uni-berlin.de...

"Quackker12" <ja******@netzero.net> wrote in message news:1e**************************@posting.google.c om...
I have Turbo C 2.0, and in layer3.c, a variable called mantisa is
defined as:

unsigned long mantisa: 27;


Is mantisa a member of a structure? If not, then it's illegal to
define/declare bit-fields like this.
The compiler says that the bit width is too large. How do I fix the
code so I can compile it?

Moreover, the bit-field width is quite ok since, long are, at least, 32 bits wide.
regards,

ja******@netzero.net


Nov 14 '05 #3
On Tue, 8 Jun 2004, Quackker12 wrote:
I have Turbo C 2.0, and in layer3.c, a variable called mantisa is
defined as:

unsigned long mantisa: 27;

The compiler says that the bit width is too large. How do I fix the
code so I can compile it?


Assuming it is just a matter of your compiler having a 16 bit long, you'll
have to check your compiler to see if there is an option to use 32 bit
long. Turbo C 2.0 is a *VERY* old compiler. It is entirely possible that
it does not support the ANSI C standard and has a 16 bit long (Windows 3.1
and older).

Even if you can get passed this problem you are probably going to find
other problems a new programmer shouldn't have to deal with. I would
recommend you search for "djgpp" or "cygwin". This will find an
implementation of the popular gcc compiler for MSDOS. It is free and much
more current.

--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vi************@whitehouse.gov
Nov 14 '05 #4
On Wed, 9 Jun 2004, Vijay Kumar R Zanvar wrote:

"Vijay Kumar R Zanvar" <vi*****@globaledgesoft.com> wrote in message
news:2i************@uni-berlin.de...

"Quackker12" <ja******@netzero.net> wrote in message
news:1e**************************@posting.google.c om...
I have Turbo C 2.0, and in layer3.c, a variable called mantisa is
defined as:

unsigned long mantisa: 27;


Is mantisa a member of a structure? If not, then it's illegal to
define/declare bit-fields like this.
The compiler says that the bit width is too large. How do I fix the
code so I can compile it?


Moreover, the bit-field width is quite ok since, long are, at least, 32
bits wide.


You are assuming the compiler is ANSI C compliant. I started programming C
before the ANSI C standard (1989) and I remember using Turbo C 2.0. I
cannot remember for sure but I believe either Turbo C 1.5 or 2.0 predates
the ANSI C standard. It is entirely possible that the compiler uses a 16
bit long.

--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vi************@whitehouse.gov
Nov 14 '05 #5
On 9 Jun 2004 12:48:52 GMT, da*****@NOMORESPAMcs.utoronto.ca.com
(Darrell Grainger) wrote:
Moreover, the bit-field width is quite ok since, long are, at least, 32
bits wide.


You are assuming the compiler is ANSI C compliant. I started programming C
before the ANSI C standard (1989) and I remember using Turbo C 2.0. I
cannot remember for sure but I believe either Turbo C 1.5 or 2.0 predates
the ANSI C standard. It is entirely possible that the compiler uses a 16
bit long.


c:\tc>type width.c
#include <stdio.h>

int main(void)
{
printf("sizeof short: %d\n", sizeof(short));
printf("sizeof long : %d\n", sizeof(long));
printf("sizeof int : %d\n", sizeof(int));
return(1);
}

c:\tc>tcc -ml width.c
Turbo C Version 2.01 Copyright (c) 1987, 1988 Borland International
Turbo Link Version 2.0
[trimmed]

c:\tc>width
sizeof short: 2
sizeof long : 4
sizeof int : 2

The readme accompanying this version of Turbo C (most of the files are
dated May 11, 1989) makes note of a change in the ANSI draft about
labels, so it seems that Borland kept fairly well abreast of the
changes being made to the language.

As for the sizes of a long, the simple example above illustrates.
shorts and ints were 16-bits (the size of the x86's registers), while
longs were a full 32-bits. I believe that fact holds true for every
16-bit real-mode compiler ever produced for MS-DOS/16-bit Windows
systems.

Of course, I'm horribly off-topic for comp.lang.c. :)

--
AndrewJ
Nov 14 '05 #6
Quackker12 wrote:
I have Turbo C 2.0, and in layer3.c, a variable called mantisa is
defined as:

unsigned long mantisa: 27;

The compiler says that the bit width is too large. How do I fix the
code so I can compile it?


Others have mentioned that this syntax makes sense only
if `mantisa' is an element of a struct or union. There's no
hope of getting this to do anything sensible if `mantisa' is
a free-standing variable.

If `mantisa' *is* a struct or union element, the only
valid "base" types are the various flavors of `int' (and,
in the latest "C99" Standard, `_Bool'). A compiler is
allowed to accept `long' as the base type, but is not
required to do so.

Finally, the compiler is not required to accept a bit
count wider than the compiler's notion of `int'. Even if
the compiler supports a 32-bit `long' -- or a 64-bit `long'
or a 128-bit `long' -- it need not accept anything wider
than `int' as a bit field width.

Summary: There might not be anything you can do about
the problem, short of finding a different compiler.

--
Er*********@sun.com

Nov 14 '05 #7
Darrell Grainger wrote:
On Tue, 8 Jun 2004, Quackker12 wrote:
I have Turbo C 2.0, and in layer3.c, a variable called mantisa
is defined as:

unsigned long mantisa: 27;

The compiler says that the bit width is too large. How do I
fix the code so I can compile it?


Assuming it is just a matter of your compiler having a 16 bit
long, you'll have to check your compiler to see if there is an
option to use 32 bit long. Turbo C 2.0 is a *VERY* old compiler.
It is entirely possible that it does not support the ANSI C
standard and has a 16 bit long (Windows 3.1 and older).


TC 2 supports the draft ANSI-89 standard. It is close to
compliant. The OPs problem has nothing to do with the size of
longs. I assume that declaration is part of a structure
definition (otherwise it is a syntax error) which the OP should
have shown in full. At any rate bit fields are sited in ints, not
longs. TC2 ints are 16 bits.

I suspect the OP is trying to play games with the floating
representation. That is unstandardized (in C), and would be
better (and non-portably, thus off topic) handled by examining the
byte patterns.

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Nov 14 '05 #8
Eric Sosman <Er*********@sun.com> wrote in message news:<40**************@sun.com>...
Quackker12 wrote:
I have Turbo C 2.0, and in layer3.c, a variable called mantisa is
defined as:

unsigned long mantisa: 27;

The compiler says that the bit width is too large. How do I fix the
code so I can compile it?


Others have mentioned that this syntax makes sense only
if `mantisa' is an element of a struct or union. There's no
hope of getting this to do anything sensible if `mantisa' is
a free-standing variable.

If `mantisa' *is* a struct or union element, the only
valid "base" types are the various flavors of `int' (and,
in the latest "C99" Standard, `_Bool'). A compiler is
allowed to accept `long' as the base type, but is not
required to do so.

Finally, the compiler is not required to accept a bit
count wider than the compiler's notion of `int'. Even if
the compiler supports a 32-bit `long' -- or a 64-bit `long'
or a 128-bit `long' -- it need not accept anything wider
than `int' as a bit field width.

Summary: There might not be anything you can do about
the problem, short of finding a different compiler.


Here is the structure that defines it:

static
struct fixedfloat {
unsigned long mantissa : 27;
unsigned short exponent : 5;
} const rq_table[8207] = {
# include "rq_table.dat"

Anyway, it looks like that I may need a new compiler. Can anyone
suggest a non 32-bit compiler that can handle this? (I am trying a
noble goal of writing a mp3 player for older machines...)

TIA
Nov 14 '05 #9
ja******@netzero.net (Quackker12) wrote:
Eric Sosman <Er*********@sun.com> wrote:
If `mantisa' *is* a struct or union element, the only
valid "base" types are the various flavors of `int' (and,
in the latest "C99" Standard, `_Bool'). A compiler is
allowed to accept `long' as the base type, but is not
required to do so.

Finally, the compiler is not required to accept a bit
count wider than the compiler's notion of `int'. Even if
the compiler supports a 32-bit `long' -- or a 64-bit `long'
or a 128-bit `long' -- it need not accept anything wider
than `int' as a bit field width.

Summary: There might not be anything you can do about
the problem, short of finding a different compiler.


Here is the structure that defines it:

static
struct fixedfloat {
unsigned long mantissa : 27;
unsigned short exponent : 5;
} const rq_table[8207] = {
# include "rq_table.dat"

Anyway, it looks like that I may need a new compiler. Can anyone
suggest a non 32-bit compiler that can handle this? (I am trying a
noble goal of writing a mp3 player for older machines...)


TC 3 might be a bit better. Also you could investigate Watcom C
(I have a licenced copy of Watcom C for DOS. Recently they went
free and open-source, but I don't know if that applies to their
DOS versions retrospectively).

Of course, you could rewrite the code to not use those bitfields
(an excellent idea, since it's non-standard to use 'short' and
'long' as the types, as Eric pointed out).
Try something like:

assert(sizeof(long) * CHAR_BIT == 32);
#define MANTISSA(x) ( (unsigned long)(x) >> 5)
#define EXPONENT(x) ( (x) & 0x1FUL)
#define M_E(m,e) ((m##UL << 5) | e##UL)
const unsigned long rq_table[8207] = {
M_E(123,456),

etc.
Nov 14 '05 #10
kal
ja******@netzero.net (Quackker12) wrote in message news:<1e**************************@posting.google. com>...
static
struct fixedfloat {
unsigned long mantissa : 27;
unsigned short exponent : 5;
} const rq_table[8207] = {
# include "rq_table.dat"


May be the following will work if the objective is to
get the float values.

static const float float_table[8207];

struct fixedfloat {
unsigned long m;
unsigned short e;
} const rq_table[8207] = {
# include "rq_table.dat"
}

unsigned long u;
for (int i=0; i<8207; i++)
{
u = ((unsigned long)rq_table[i].e << 27) |
((unsigned long)rq_table[i].m);
float_table[i] = *((float *)(&u));
}
Nov 14 '05 #11
On 9 Jun 2004 23:44:35 -0700, ol*****@inspire.net.nz (Old Wolf) wrote:
Anyway, it looks like that I may need a new compiler. Can anyone
suggest a non 32-bit compiler that can handle this? (I am trying a
noble goal of writing a mp3 player for older machines...)


TC 3 might be a bit better. Also you could investigate Watcom C
(I have a licenced copy of Watcom C for DOS. Recently they went
free and open-source, but I don't know if that applies to their
DOS versions retrospectively).


<OT>
OpenWatcom (http://www.openwatcom.org). Just about everything is
"open", although it's under their own license and not one of the more
popular "open source" licenses like the GPL. Basically, everything
that was actually produced by the Watcom developers is available.
Acquiring the SDK's for various platforms is up to the end user. OW
includes both the 16-bit and 32-bit C and C++ compilers, as well as
the Fortran compilers.

AFAIK, the freedoms of the current license does not apply to previous
versions of the software, as many of the components are licensed from
3rd parties and not really redistributable.
</OT>

--
Andrew
--
Andrew
Nov 14 '05 #12

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

Similar topics

2
2072
by: Tom Loredo | last post by:
Hi folks- I'm about to move from a Solaris 8/SPARC environment to a Dell running RedHat 9. Are there any issues I need to be aware of in bringing my Python code over (mostly scientific...
28
2765
by: grahamd | last post by:
Who are the appropriate people to report security problems to in respect of a module included with the Python distribution? I don't feel it appropriate to be reporting it on general mailing lists.
5
4672
by: sandy | last post by:
Hi All, I am a newbie to MySQL and Python. At the first place, I would like to know what are the general performance issues (if any) of using MySQL with Python. By performance, I wanted to...
2
2266
by: malcolm | last post by:
Hello, We have a robust (.NET 1.1 c# winforms) client-server application that utilizes many typed DataSets, typed DataTables and typed DataRows. Our application is a series of windows and popup...
1
1657
by: Aliandro | last post by:
Hi Does any one know where I can find information regarding any issues with SQL and IIS being run under windows XP SP2? as I am in the process of programmning in Dot net and neet some way of...
7
1836
by: David Laub | last post by:
I have stumbled across various Netscape issues, none of which appear to be solvable by tweaking the clientTarget or targetSchema properties. At this point, I'm not even interested in "solving"...
2
3035
by: G2 | last post by:
Hi We are dealing with significant browser compatibility issues with Netscape 5.x+ browsers and Mac IE. I am sure most web developers have faced similar issues in the past. Can anyone give me their...
1
1944
by: GaryDean | last post by:
We have been developing all of our .net applications on 32 bit windows using 32 bit SQL Server. We are being asked to now deploy to servers running 64bit windows and 64bit SQL Server. Are there...
3
1636
by: eschneider | last post by:
Just some common issues with WS: Using custom objects: When objects change, seems you are always fixing some issue. Update references, which sometimes does not work. Deployment: Weird errors...
0
7221
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
7109
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
7313
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,...
1
7029
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...
0
7481
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...
0
4702
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...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1537
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 ...
1
758
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.