我在MATLAB / Simulink c-mex s函数中使用以下代码得到分段错误:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
driver = webdriver.Firefox()
driver.get("https://stackoverflow.com/questions")
try:
WebDriverWait(driver, 3).until(EC.presence_of_element_located(
(By.XPATH, '//div[@id="tabs"]/a[@class="youarehere"]')))
print "Page is ready!"
except TimeoutException:
print "Time exceeded"
noofquestionsperpage = driver.find_element_by_xpath(
'//div[@class="page-sizer fr"]/a[@class="page-numbers current"]').text
requirednumberofposts = 30
numberofpagesclick = requirednumberofposts / int(noofquestionsperpage)
if numberofpagesclick > 1:
for i in range(numberofpagesclick):
for j in range(int(noofquestionsperpage)):
xpath = "//div[@id='questions']/div[" + \
str(j + 1) + "]/div[2]/h3/a"
print driver.find_element_by_xpath(xpath).get_attribute('href')
try:
driver.find_element_by_xpath(
'//div[@class="pager fl"]/a[6]/span[@class="page-numbers next"]').click()
except:
print "All questons loaded"
在class Circle
{
public:
Circle()
{
mexPrintf("circle_constructor");
}
void draw_circle()
{
mexPrintf("circle");
// code for drawing circle
}
};
class Master
{
private:
Circle *member_circle;
public:
Master()
{
member_circle = new Circle();
}
void draw()
{
member_circle->draw_circle();
}
};
Master *master_object;
- 函数中我使用
mdlStart
并在master_object = new Master();
- 函数中使用
mdlOutputs
最后一次功能调用会导致分段违规错误。我在这里发布了一个关联问题(Segmentation fault when calling class from matlab),但我发现每当我尝试将对象(master_object->draw()
)作为属性存储在另一个类({{1 }})。
你知道如何为MATALB c-mex函数解决这个问题,因为这些函数在MATLAB之外工作吗?感谢。