473,976 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error: non-lvalue in assignment

8 New Member
Hi Everybody

the compiler throws an error when it runs this function in my code, I couldn't figure out what is wrong with my code, please assist me, thanks :).

Expand|Select|Wrap|Line Numbers
  1. void SMAC::IncreaseCW() {
  2. init rI=2;
  3. DATA_CW=DATA_CW*rI;
  4. double cw = (Random::random() % DATA_CW) * slotTime_sec_;
  5. mhCS_.sched(CLKTICK2SEC(difs_) + cw);
  6.  
Expand|Select|Wrap|Line Numbers
  1. mac/smac.cc: In member function `void SMAC::IncreaseCW()':
  2. mac/smac.cc:463: error: non-lvalue in assignment
  3.  
May 12 '09 #1
10 10527
Banfa
9,065 Recognized Expert Moderator Expert
init rI=2;
Did you mean int?
May 12 '09 #2
JosAH
11,448 Recognized Expert MVP
@Banfa
DATA_CW suggests to be a macro name ... who knows?

kind regards,

Jos
May 12 '09 #3
muby
8 New Member
sorry folks, i meant
int rI = 2;
im still facing the same error, any help? thx :)
May 12 '09 #4
scruggsy
147 New Member
Your error says line 463. Which of those lines is 463?

You have an assignment involving something called DATA_CW, but you didn't post the code which defines DATA_CW.

More info == more help.
May 12 '09 #5
JosAH
11,448 Recognized Expert MVP
@muby
Did you read the error message and did you check the line your compiler complained about? Learn how to read error messages; it'll be a lot faster than posting here everytime you see one.

kind regards,

Jos
May 12 '09 #6
muby
8 New Member
Thanks for your reply, the line where im getting error is shown below,
I defined DATA_CW in header file as
#define DATA_CW 63
Expand|Select|Wrap|Line Numbers
  1. # void SMAC::IncreaseCW() {
  2. # int rI=2;
  3. # DATA_CW=DATA_CW*rI; # error is in this line (line 463)
  4. # double cw = (Random::random() % DATA_CW) * slotTime_sec_;
  5. # mhCS_.sched(CLKTICK2SEC(difs_) + cw);
  6. }
May 12 '09 #7
newb16
687 Contributor
After preprocessing it's expanded to
63 = 63*2;

Left part is a number here, you can't assign to numbers. What are you trying to do?
May 12 '09 #8
muby
8 New Member

IncreaseCW
should increases the value of DATA_CW by doubling the old value of DATA_CW, and assigne the new value back to DATA_CW. this new value will be used in other functions.

I changed it as shown below, but im still getting the same error.

Expand|Select|Wrap|Line Numbers
  1. void SMAC::IncreaseCW() {
  2. int DATA_CW_new;
  3. DATA_CW_new = (DATA_CW*rateincrease);
  4. DATA_CW = DATA_CW_new;
  5. double cw = (Random::random() % DATA_CW) * slotTime_sec_;
  6. mhCS_.sched(CLKTICK2SEC(difs_) + cw);
  7. }
May 12 '09 #9
scruggsy
147 New Member
Read newb16's post again.
DATA_CW is a macro, not a variable. It is replaced by the compiler with '63' wherever it occurs in your code. You cannot assign to it. Use a variable.
May 12 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5058
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
1
1920
by: Sean Abrahams | last post by:
The following is a reprint of a message I sent to the tutor list a long time ago, that I haven't gotten around to discussing with anyone else and failed to hear a reply on the tutor list. Hoping someone here may want to have some dialog. -- I'm learning to write unit tests and am trying to write them for a web application I'm working on.
4
4030
by: muser | last post by:
Can anyone run this program through their compiler or if they can see a logical error please point it out. I have my tutor working on it at the moment but I would rather a less ambigious response than the one I think he will provide. The test data, A:\\"514650.txt", appears at the end of the program. The problem is that the program won't read this file and the debugger as far as i know how to work it won't point out the mistake of any....
0
3059
by: Morten Gulbrandsen | last post by:
mysql> USE company; Database changed mysql> mysql> DROP TABLE IF EXISTS EMPLOYEE; -------------- DROP TABLE IF EXISTS EMPLOYEE -------------- Query OK, 0 rows affected (0.00 sec)
13
2498
by: a.zeevi | last post by:
free() multiple allocation error in C ==================================== Hi! I have written a program in C on PC with Windows 2000 in a Visual C environment. I have an error in freeing multiple allocation as follows: 1. I allocated an array of pointer. 2. I Read line by line from a text file. 3. I allocated memory for the read line.
22
3307
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of seats as 0 and the flight no. is also repeating. If any can tell why is this please help me. #include<stdio.h> #include<ctype.h> #include<conio.h>
2
6147
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my pointers, but I'm not sure. Please help. The code: void equate(matrix *A, matrix *B) { int i, j; assert(A.row_dim == B.col_dim && A.col_dim == B.col_dim); for(i=0; i < A.row_dim; i++) for(j=0; j < A.col_dim; j++)
1
2765
by: Alexander Higgins | last post by:
>>Thanks for the response.... Point Taken but this is not the case. Thus, if a person writes a text file on her or his computer and does not use UNICODE to save it, the current code page is used. If this file is given to someone with some other current codepage, the file is not displayed correctly. Simply converting the file to Unicode will make the data display properly. When performing the encoding process the encoding will escape...
13
3833
by: Albert | last post by:
Hi I'm using the lcc compiler for win32. I tried compiling a program but there's an error stating: "cpp: Can't open input file clrscr()" I don't get it - I've included <tcconio.h>. (strange why they couldn't have just left it as <conio.h>?): #include <tcconio.h> // code
2
5601
DonRayner
by: DonRayner | last post by:
This one has me stumped. I'm getting a "Type Mismatch" error on one of my forms when it's being opened. It's hapening before the forms "On Open" event, I stuck a msgbox in there to check and I'm getting the error before it opens. The line of code that calls the form from another form is. DoCmd.OpenForm "NonConformanceAdd",,,,acFormAdd,acDialog I get the error, click ok, then the form opens and works exactly how it's supposed to. I even...
0
10349
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10162
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
11811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11566
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
10078
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
7601
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
6411
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
5149
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
3
3756
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.