question

Quantum7-1813 avatar image
0 Votes"
Quantum7-1813 asked ·

Too many lines of code causing linking errors...

I'm running visual studio 2017 with visual c++ CLR. There seems to be a lot of code in my form1.h header file, to the point of causing linking errors. I was thinking that I might be able to store code in cpp files and write to the form1.h file from the cpp files. How do I write to the h file from cpp files?

c++
· 11
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Maybe the errors are caused by some other issues?

0 Votes 0 ·

@Quantum7-1813

According to the issue, whether you want to split the declaration and implementation in C++/CLI? If so I suggest you could refer to the thread: https://social.msdn.microsoft.com/Forums/vstudio/en-US/e08ce967-b5d8-4457-93a9-f549d37b1807/ccli-headers?forum=vclanguage

Too many lines of code causing linking errors...

Could you please provide a sample code to help us reproduce the issue?


0 Votes 0 ·
Quantum7-1813 avatar image Quantum7-1813 JeanineZhang-MSFT ·

Can I e-mail you the form header file and the dll code? The code is getting big and bigger as soon as I can get these errors worked out.

0 Votes 0 ·
Quantum7-1813 avatar image Quantum7-1813 JeanineZhang-MSFT ·

If you don't want to post your e-mail on here, I'll just post you mine and you can e-mail me. Then I'll e-mail you a zip file if I can or I'll put it on google drive. quantumgss7@gmail.com

0 Votes 0 ·

@Quantum7-1813

Could you please share directly to Onedrive?

0 Votes 0 ·
Show more comments

1 Answer

JeanineZhang-MSFT avatar image
0 Votes"
JeanineZhang-MSFT answered ·

Hi,

Too many lines of code causing linking errors...

I have tried the code you provided, and there was no link error. Could you please provide more details about the link error message?

And while testing your code, I found the following problems.

1,Like I said in the other two threads you posted, When you add controls to the form, vs will automatically instantiate the object, and you couldn't need to repeat by yourself.

2,As far as I'm concerned, the assignment logic of your text box inputs is reversed. You should try to use in1 = textBox1->Text; instead of textBox1->Text = in1;

I suggest you could refer to the following code:

 String^ in1;
 //System::Windows::Forms::TextBox^ textBox1;
 //textBox1->Text = in1;
 in1 = textBox1->Text;
    
 String^ in2;
 //System::Windows::Forms::TextBox^ textBox2;
 //textBox2->Text = in2;
 in2 = textBox2->Text;
    
 String^ in3;
 //System::Windows::Forms::TextBox^ textBox3;
 //textBox3->Text = in3;
 in3 = textBox3->Text;
    
 String^ in4;
 //System::Windows::Forms::TextBox^ textBox4;
 //textBox4->Text = in4;
 in4 = textBox4->Text;
    
 String^ in5;
 //System::Windows::Forms::TextBox^ textBox5;
 //textBox5->Text = in5;
 in5 = textBox5->Text;
    
    
    
    
    
    
    
 modulator^oInst = gcnew modulator();
 double etresult = oInst->main(element_total);
 String^ out1 = Convert::ToString(etresult);
 //System::Windows::Forms::TextBox^ textBox6;
 textBox6->Text = out1;
            
 modulator ^oInst1 = gcnew modulator();
 double cresult = oInst1->main(c_nmw);
 modulator ^oInst2 = gcnew modulator();
 double hresult = oInst2->main(h_nmw);
 modulator ^oInst3 = gcnew modulator();
 double nresult = oInst3->main(n_nmw);
 modulator ^oInst4 = gcnew modulator();
 double oresult = oInst4->main(o_nmw);
 modulator ^oInst5 = gcnew modulator();
 double presult = oInst5->main(p_nmw);
 double long color_result = cresult + hresult + nresult + oresult + presult;
 modulator ^oInst6 = gcnew modulator();
 double c_result = oInst6->main(color_result);
 String^ out2 = Convert::ToString(c_result);
 //System::Windows::Forms::TextBox^ textBox7;
 textBox7->Text = out2;
            
 double long mix_result = etresult + c_result;
 modulator ^oInst7 = gcnew modulator();
 double m_result = oInst7->main(mix_result);
 String^ out3 = Convert::ToString(m_result);
 //System::Windows::Forms::TextBox^ textBox8;
 textBox8->Text = out3;

3,In mod1.h, there is a problem with your loop logic. When modinput is greater than 780.9 * 2, modinput must also be greater than 780.9,and so on... And the return value is outside the while loop, so there is no way to jump out of the loop and cause the program to not respond. I suggest that you could compare in segments, such as 780.9~780.9*2,780.9*2~780.9*4, and so on... and you could add the return value in each if statement.

I suggest you could refer to the following code:


 if (780.9<modinput <= 780.9*2) {
 modpass = modinput / 2;
 return modpass;
 };
 if (780.9*2 < modinput <= 780.9 * 4) {
 modpass = modinput / 4;
 return modpass;
 };
 ……

Best Regards,

Jeanine





If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.